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

           Summary: <cmath> undefs symbols from the global namespace
           Product: libc++
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


$ cat test.cc
#include <math.h>

void foo(double works) {
    isnan(works);
}

#include <cmath>

void bar(double doesnt) {
    isnan(doesnt);
}
$ clang++ -stdlib=libc++ -c test.cc 
test.cc:10:5: error: use of undeclared identifier 'isnan'
    isnan(doesnt);
    ^
1 error generated.


This is basically the same issue as http://gcc.gnu.org/PR14608.
[depr.c.headers] says that <math.h> puts the <cmath> names into the global
namespace, and it doesn't allow a later include of <cmath> to take them back
out. [depr.c.headers] also allows <cmath> to 'using' its declarations and
definitions into the global namespace, which is what I'd propose as a fix.

One twist is that glibc's <math.h> defines at least isnan and isinf as
functions in the global namespace rather than just macros, so you can't simply
add that using declaration on all platforms.

-- 
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