This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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]

Re: Avoid some left-shifts of negative constants


On Thu, 7 Feb 2019, Paul Eggert wrote:

> fragile. Surely it would be easy to fix UBSAN to not report an error for a
> left shift of a negative value, for applications like glibc that are willing
> to rely on GCC's semantics.

I think such errors are like many compiler warnings - they may not 
necessarily indicate a bug, but they indicate something suspicious in the 
code, that requires extra thought to determine whether the code there is 
correct or not (compared to code doing shifts on unsigned values that can 
be more obviously correct without thinking about what happens with sign 
bits in that particular case).  If the code is doing left shifts of 
negative values, that may well indicate an unsigned type would have made 
the intended semantics clearer, even if a signed type does work in that 
code.

-- 
Joseph S. Myers
joseph@codesourcery.com


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