On 12/01/2015 10:15 AM, Andrew Haley wrote:
On 12/01/2015 05:11 PM, Martin Sebor wrote:
On 12/01/2015 09:07 AM, Andrew Haley wrote:
Do we support left shift of a negative value? Technically it's
undefined and ubsan warns about it. However, a ton of software would
surely break if we didn't do the obvious right thing. I can't find
anything in the GCC manual.
I believe gcc does the expected thing but see bug 65179:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=65179
There have been discussions on gcc-patches about some of
the issues the warning has exposed (real or otherwise),
for example:
https://gcc.gnu.org/ml/gcc-patches/2015-05/msg00696.html
OK, thanks. I wonder if we should document this as a GCC extension.
Leaving it up in the air like this does no-one any good.
I assume you're suggesting that the result produced by GCC for such
expressions should be documented. I agree with that. After checking
the C Implementation section of the manual I believe it's covered by
section 4.5, Integers (bullet 5):
https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html#Integers-implementation
Martin