[llvm-bugs] [Bug 39914] Incorrect code when right shifting signed int by more than its size

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Dec 7 06:26:55 PST 2018


Hal Finkel <hfinkel at anl.gov> changed:

           What    |Removed                     |Added
         Resolution|---                         |INVALID
             Status|NEW                         |RESOLVED

--- Comment #1 from Hal Finkel <hfinkel at anl.gov> ---
While I understand why you think that should be true, given how the operation
might work at the hardware level, the C/C++ specifications don't define the
behavior of shifts greater-than or equal-to the number of bits in the type.
Clang's behavior here is not a bug. The optimizer optimizes code assuming that
code that exhibits undefined behavior is not actually executed (and, thus, it
doesn't really matter what it does). You might find it useful to compile your
code with -fsanitize=undefined to enable the undefined-behavior sanitizer.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181207/f7141e74/attachment.html>

More information about the llvm-bugs mailing list