[Bug c/78135] In an unsigned long (64 bit) 1<<31 gives rubbish
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Oct 27 18:00:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78135
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> wk = 0x100000000 << j;
>
> That is still int << j
That is not true, that is actually either long int << j or long long int << j
on most targets (e.g. LP64 the former and ILP32 the latter).
Otherwise, on 32-bit int targets, 1 << 31 is defined in C++, but is INT_MIN
then,
i.e. negative, and undefined behavior in C99/C11 (just try
-fsanitize=undefined).
And, again on 32-bit int targets, (1 << 24) << 7 is well defined, but 0.
More information about the Gcc-bugs
mailing list