[LLVMbugs] [Bug 23705] Different result (integer wrap) by optimization setting
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sat May 30 03:19:05 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=23705
David Majnemer <david.majnemer at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |david.majnemer at gmail.com
Resolution|--- |INVALID
--- Comment #1 from David Majnemer <david.majnemer at gmail.com> ---
Apple's distribution of clang is not supported on llvm.org. That being said,
your code makes use of undefined behavior which permits clang to optimize it
ways which seem logically contradictory.
$ clang -fsanitize=undefined t.c -o t
$ ./t
t.c:12:24: runtime error: signed integer overflow: -2147483648 - 1073741823
cannot be represented in type 'int'
A
What this indicates is that GetB() - c results in undefined behavior because it
wraps.
If you want the compiler to give you two's complement results even when signed
integer overflow occurs, use -fwrapv.
--
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/20150530/94ef63d1/attachment.html>
More information about the llvm-bugs
mailing list