http://llvm.org/bugs/show_bug.cgi?id=3354
Summary: apparent bad interaction between math and short-circuit
Product: new-bugs
Version: unspecified
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: new bugs
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
The attached program displays this behavior on x86 Linux:
[reg...@babel tmp30]$ llvm-gcc -O small.c -o small
small.c: In function âmainâ:
small.c:19: warning: division by zero
small.c:19: warning: division by zero
[reg...@babel tmp30]$ ./small
x=1
Floating point exception
The thing is, the divide-by-zero behaviors are all protected by
short-circuiting operations, and should never fire. I claim that LLVM's -O0
behavior is what must occur at all optimization levels:
[reg...@babel tmp30]$ llvm-gcc -O0 small.c -o small
small.c: In function âmainâ:
small.c:19: warning: division by zero
small.c:19: warning: division by zero
[reg...@babel tmp30]$ ./small
x=1
x=0
The macro in the attached code is simply a macroized version of the 2nd safe
multiplication fragment here:
https://www.securecoding.cert.org/confluence/display/cplusplus/INT32-CPP.+Ensure+that+operations+on+signed+integers+do+not+result+in+overflow
--
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs