[LLVMbugs] [Bug 8542] Clang miscompiles valid code with -O2 on x86 and x86-64

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Nov 3 15:07:12 PDT 2010


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

Nick Lewycky <nlewycky at google.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |nlewycky at google.com
         Resolution|                            |INVALID

--- Comment #1 from Nick Lewycky <nlewycky at google.com> 2010-11-03 17:07:11 CDT ---
The original code is invalid:

unsigned int rotate_right(unsigned int input, unsigned int rot)
   {
   return ((input >> rot) | (input << (32-rot)));
   }

When rot = 0, 32-rot = 32 and this performs "input << 32" which has undefined
behaviour and can produce any value we want to, even different numbers each
time.

The real code is buggy and needs to be fixed.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list