[LLVMbugs] [Bug 9854] New: <cmath> undefs symbols from the global namespace

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu May 5 17:52:51 PDT 2011


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: hhinnant at apple.com
        ReportedBy: jyasskin at google.com
                CC: llvmbugs at cs.uiuc.edu


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



More information about the llvm-bugs mailing list