https://llvm.org/bugs/show_bug.cgi?id=23705
Bug ID: 23705
Summary: Different result (integer wrap) by optimization
setting
Product: tools
Version: 3.5
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: llvm-gcc
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
On Mac OS X 10.10.3, Apple LLVM 6.0, with no optimization (-O0) or -O1, print
"A" (expected result).
However, with optimization (-Os), print "B" (not expected result).
file 1
-------------------
#include <stdio.h>
extern int GetA();
extern int GetB();
extern int GetC();
int main()
{
int a = GetA();
int c = GetC();
int d = GetB() - c;
if ((a - c) < (d))
{
puts("A");
}
else
{
puts("B");
}
return 0;
}
-------------------
file 2
-------------------
#include <limits.h>
int GetA()
{
return INT_MAX;
}
int GetB()
{
return INT_MIN;
}
int GetC()
{
return INT_MAX / 2;
}
-------------------
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs