gcc bug

Nathan Sidwell nathan@codesourcery.com
Mon Mar 6 01:55:00 GMT 2000

Pawel Palucha wrote:

> Perhaps I'm wrong, but I though that "unsigned long k = 1UL << 32" is the
> same as "int i = 32; unsigned long k = 1UL << i".
No. `expr << shift' invokes undefined behaviour when `shift' is negative
or greater or equal to the length in bits of `expr'. You have 32bit
longs, so have invoked undefined behaviour -- anything can happen.

Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org

More information about the Gcc-bugs mailing list