question about shift operator

Guy Harris guy at auspex.UUCP
Wed Nov 2 19:24:40 AEST 1988


>     int n;
>     n <<= 32;
>
>K&R 1st ed. seems to indicate the operation is undefined, but does
>the proposed standard change this?  

No.  If you depend on it doing something in particular, you will lose. 
There exist quite common machines on which shift counts are not taken
modulo the word size (68K) and quite common machines on which it is
(80386), and chances are the compiler will just generate a shift
instruction and not add extra code to check whether the shift count is
larger than the word size.



More information about the Comp.lang.c mailing list