[LLVMbugs] [Bug 10409] New: -O0 not turn off all "optimizations"

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jul 19 09:49:14 PDT 2011


           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: unassignedbugs at nondot.org
        ReportedBy: tydeman at tybor.com
                CC: llvmbugs at cs.uiuc.edu

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>

int main(void){
  double x;
  int i;


  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.

More information about the llvm-bugs mailing list