This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: gcc bug


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.

nathan
-- 
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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]