On 12/04/2015 10:51 AM, Paolo Bonzini wrote:


On 25/11/2015 14:55, Paolo Bonzini wrote:
Left shifts into the sign bit is a kind of overflow, and the
standard chooses to treat left shifts of negative values the
same way.

However, the -fwrapv option modifies the language to one where
integers are defined as two's complement---which also defines
entirely the behavior of shifts.  Disable sanitization of left
shifts when -fwrapv is in effect.  The same change was proposed
for LLVM at https://llvm.org/bugs/show_bug.cgi?id=25552.

Bootstrapped/regtested x86_64-pc-linux-gnu.  Ok for trunk, and for
GCC 5 branch after 5.3 is released?

Thanks,

Paolo

gcc:
        PR sanitizer/68418
        * c-family/c-ubsan.c (ubsan_instrument_shift): Disable
        sanitization of left shifts for wrapping signed types as well.

gcc/testsuite:
        PR sanitizer/68418
        * gcc.dg/ubsan/c99-wrapv-shift-1.c,
        gcc.dg/ubsan/c99-wrapv-shift-2.c: New testcases.
Doesn't this change how pointer types are handled?

jeff

Reply via email to