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]
Other format: [Raw text]

[Bug c/78135] In an unsigned long (64 bit) 1<<31 gives rubbish


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));

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