[llvm-bugs] [Bug 41875] Incorrect code is generated for rotation of 32-bit value to 32-bits
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue May 14 08:48:38 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=41875
Sanjay Patel <spatel+llvm at rotateright.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
CC| |spatel+llvm at rotateright.com
Status|NEW |RESOLVED
--- Comment #1 from Sanjay Patel <spatel+llvm at rotateright.com> ---
The function invokes undefined behavior, so anything is possible.
You can test for that by adding a 'main' wrapper and:
$ clang -fsanitize=undefined 41875.c
$ ./a.out
41875.c:9:14: runtime error: shift exponent 32 is too large for 32-bit type
'uint32_t' (aka 'unsigned int')
For safe code and likely better code optimization, you may want to use the
clang builtins for bitwise rotation:
https://clang.llvm.org/docs/LanguageExtensions.html#builtin-functions
--
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/20190514/199a02db/attachment.html>
More information about the llvm-bugs
mailing list