http://llvm.org/bugs/show_bug.cgi?id=10409
Summary: -O0 not turn off all "optimizations"
Product: new-bugs
Version: 2.8
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: new bugs
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
It appears, that even with -O0, some "optimizations" are being done.
These optimizations change the semantics (meaning) of the code and
do the wrong thing. One such item is constant folding.
#include <fenv.h>
#include <stdio.h>
#pragma STDC FENV_ACCESS ON
int main(void){
double x;
int i;
feclearexcept(FE_ALL_EXCEPT);
x = 1.0;
x /= 3.0; /* should raise inexact;
value computed depends upon rounding direction */
i = fetestexcept(FE_ALL_EXCEPT);
if( FE_INEXACT != i ){
printf("missing inexact (got %i), x=%g\n", i, x);
}
return 0;
]
If I add 'volatile' to the declaration of x, then the code works.
The same kind of problem happens for:
x=1.0; x /= 0.0; /* divide by zero */
x=0.0; x /= 0.0; /* invalid */
x=DBL_MAX; x *= DBL_MAX; /* overflow */
x=DBL_MIN; x *= DBL_MIN; /* underflow */
--
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