Daniel Kraft <d@domob.eu> writes:
> I did encounter a strange problem in my C program, and traced it down;
> it looks like I get different results for bit left shifts when the bit
> count is a constant or a funtion-return value.
>
> When doing (1 << 32) for a 32-bit-unsigned I expect to get 0; can I
> assume this, or is this something I should never do?
[...]
It's something you should never do. Quoting the standard,
If the value of the right operand is negative or is greater than
or equal to the width of the promoted left operand, the behavior
is undefined.
--
Keith Thompson (The_Other_Keith)
kst-u@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"