[Bug c/78135] In an unsigned long (64 bit) 1<<31 gives rubbish
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Oct 27 16:39:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78135
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Also:
printf("\n Finally: 0x%016lx, how silly can you get?\n",
(unsigned long)((1 << 24) << 7));
This is undefined as shifting into the sign bit is undefined.
use instead:
printf("\n Finally: 0x%016lx, how silly can you get?\n",
(unsigned long)((1ul << 24) << 7));
More information about the Gcc-bugs
mailing list