http://llvm.org/bugs/show_bug.cgi?id=11858

             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: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]
    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
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-November/018644.html

#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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to