(volatile) foo

Alan Mycroft am at cl.cam.ac.uk
Thu Sep 21 20:12:52 AEST 1989


In article <1989Sep17.180722.21889 at light.uucp> bvs at light.UUCP (Bakul Shah) writes:
>Is the following legal?
>	char * foo;
>	while ((volatile)foo) continue;
>
Sadly, it is legal, although it has a different effect from what many
uninitiates would expect.  It loads foo as a non-volatile variable then casts
it to an int (volatile is ignored except on lvalues which casts are not).

Perhaps good compilers would give warnings for such....



More information about the Comp.std.c mailing list