-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Description
| Bugzilla Link | 3930 |
| Resolution | INVALID |
| Resolved on | Apr 02, 2009 22:42 |
| Version | unspecified |
| OS | All |
| Reporter | LLVM Bugzilla Contributor |
Extended Description
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 ; [#uses=0]
%1 = tail call i32 @fetestexcept(i32 4) nounwind ; [#uses=1]
%2 = icmp eq i32 %1, 0 ; [#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 ; [#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 ; [#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