[cfe-commits] [PATCH RFC] Emit nsw/nuw flags for shl

Xi Wang xi.wang at gmail.com
Wed Jan 2 07:15:19 PST 2013


On 1/2/13 9:40 AM, Chris Lattner wrote:
> On Jan 2, 2013, at 4:10 AM, Richard Smith <richard at metafoo.co.uk> wrote:
>> See http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1457
>>
>> In C++11, a signed left shift is nuw but not nsw.
> 
> Also, clang intentionally follow's GCC's lead and makes some shift behavior implementation-defined to be ok:
> http://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html#Integers-implementation

You mean clang intentionally leaves out nsw/nuw for signed left shift,
right?  Thanks for the clarification!  I withdraw my patch. :)

BTW, looks like GCC 4.8 once exploited this undefined behavior and
reverted the change later.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54027

- xi



More information about the cfe-commits mailing list