[LLVMbugs] [Bug 23212] New: Regression: Miscompile with -O1 and -fsanitize=signed-integer-overflow
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Apr 13 04:26:17 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=23212
Bug ID: 23212
Summary: Regression: Miscompile with -O1 and
-fsanitize=signed-integer-overflow
Product: clang
Version: trunk
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: LLVM Codegen
Assignee: unassignedclangbugs at nondot.org
Reporter: jonathan.sauer at gmx.de
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
The following program should print 1, and it does so when compiled with clang
r234732 and either -O1 or -fsanitize=signed-integer-overflow. However, when
compiled with both -O1 *and* -fsanitize=signed-integer-overflow, it prints 0.
#include <cstdio>
int flipSign(unsigned int t)
{
return -int(t);
}
int main()
{
std::printf("%d\n", -2 == flipSign(2));
}
% ~/LLVM/build/Release+Asserts/bin/clang++ -O1 clang.cpp && ./a.out
1
% ~/LLVM/build/Release+Asserts/bin/clang++ -fsanitize=signed-integer-overflow
clang.cpp && ./a.out
1
% ~/LLVM/build/Release+Asserts/bin/clang++ -O1
-fsanitize=signed-integer-overflow clang.cpp && ./a.out
0
When compiled with clang r234147, it always prints 1. So does removing the
explicit cast to "int" in "flipSign".
The miscompile also happens with higher optimization levels, e.g. -O2, -O3 and
-Os.
Detailed clang version:
clang version 3.7.0 (trunk 234732)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
--
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/20150413/39e37fd8/attachment.html>
More information about the llvm-bugs
mailing list