[LLVMbugs] [Bug 3930] New: floating point exceptions flags are ignored in constant folding
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Thu Apr 2 19:23:31 PDT 2009
http://llvm.org/bugs/show_bug.cgi?id=3930
Summary: floating point exceptions flags are ignored in constant
folding
Product: new-bugs
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Keywords: miscompilation
Severity: normal
Priority: P2
Component: new bugs
AssignedTo: unassignedbugs at nondot.org
ReportedBy: llvm at nraynaud.com
CC: llvmbugs at cs.uiuc.edu
I toyed around with http://llvm.org/demo/index.cgi
and found that this code :
#include <stdio.h>
#include <fenv.h>
int main(int argc, char **argv) {
#pragma STDC FENV_ACCESS ON
feclearexcept(FE_DIVBYZERO);
double d = 1.0/0.0;
if (fetestexcept(FE_DIVBYZERO))
printf("error\n");
else
printf("%e\n", d);
return 0;
}
is compiled this way :
define i32 @main(i32 %argc, i8** nocapture %argv) nounwind {
entry:
%0 = tail call i32 @feclearexcept(i32 4) nounwind ; <i32>
[#uses=0]
%1 = tail call i32 @fetestexcept(i32 4) nounwind ; <i32>
[#uses=1]
%2 = icmp eq i32 %1, 0 ; <i1> [#uses=1]
br i1 %2, label %bb1, label %bb
bb: ; preds = %entry
%3 = tail call i32 @puts(i8* getelementptr ([6 x i8]* @.str, i32 0, i32
0)) nounwind ; <i32> [#uses=0]
ret i32 0
bb1: ; preds = %entry
%4 = tail call i32 (i8*, ...)* @printf(i8* noalias getelementptr ([4 x
i8]* @.str1, i32 0, i32 0), double 0x7FF0000000000000) nounwind ;
<i32> [#uses=0]
ret i32 0
}
it as basically no chance to print "error" like it does under a normal C
compiler (tested on normal gcc x86_32).
the pragma is here to tell the compiler maker to be careful in floating point
handling because there will be some tampering with the FP subsystem.
exactly the same kind of bug as Bug 3929
--
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.
More information about the llvm-bugs
mailing list