[LLVMbugs] [Bug 17975] wrong code for bit shifting integer promotion at -O1 and above on x86_64-linux-gnu

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Nov 18 11:35:28 PST 2013


http://llvm.org/bugs/show_bug.cgi?id=17975

Kay Tiong Khoo <kkhoo at perfwizard.com> changed:

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

--- Comment #1 from Kay Tiong Khoo <kkhoo at perfwizard.com> ---
I think this code creates undefined behavior based on this section of the C
standard:

    ยง6.5.7 Bitwise shift operators

    3 The integer promotions are performed on each of the operands. The type of
the result is that of the promoted left operand. If the value of the right
operand is negative or is greater than or equal to the width of the promoted
left operand, the behavior is undefined.

...

You're left-shifting an 8-bit value ('c') by 8 (the global 's' is initialized
to zero), so the compiler is free to do anything here.

Note that clang trunk with -O1 is generating the expected rotate-right
instruction here (more about that optimization and handling better-written
source is in bug 17732).

Resolving as invalid. Please reopen if you disagree.

-- 
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/20131118/5c5ee27b/attachment.html>


More information about the llvm-bugs mailing list