[LLVMbugs] [Bug 11858] New: clang should not default to -fno-math-errno

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jan 26 01:40:29 PST 2012


             Bug #: 11858
           Summary: clang should not default to -fno-math-errno
           Product: clang
           Version: 3.0
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Driver
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: jay.foad at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

If I compile with optimisation, clang turns on -fno-math-errno. This is bad
because it breaks valid programs. There's a test case below. If I compile with
"clang -O" and run it, I get "result -nan, errno 0", which is wrong because
errno should be EDOM. I'm using the 3.0rc3 release on Linux/x86_64.

This behaviour was added under PR5971 but without much rationale.

Also see the brief thread at

#include <errno.h>
#include <math.h>
#include <stdio.h>

int main(int argc, const char *argv[])
       double d;
       errno = 0;
       d = sqrt(argc - 5);
       printf("result %g, errno %d\n", d, errno);
       return 0;

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