[LLVMbugs] [Bug 9700] New: Null pointer not accepted as non-type template argument

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Apr 13 09:34:37 PDT 2011


           Summary: Null pointer not accepted as non-type template
           Product: clang
           Version: unspecified
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++0x
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: jonathan.sauer at gmx.de
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com

The following code:

template <char* Ptr>
struct A {};

char    v = ' ';

int main(int, char**)
    A<&v>    a1;    // Works
    A<0>    a2;    // Doesn't

results in the following error message:

$ /opt/bin/clang -std=c++0x clang.cpp
clang.cpp:9:4: error: non-type template argument does not refer to any
        A<0>    a2;     // Doesn't
clang.cpp:1:17: note: template parameter is declared here
template <char* Ptr>
1 error generated.

even though according to 14.3.2p1, 0 should be accepted:

"A template-argument for a non-type, non-template template-parameter shall be
one of [...] a constant expression that evaluates to a null pointer value"

My clang version:

$ /opt/bin/clang -v
clang version 3.0 (trunk 129269)
Target: x86_64-apple-darwin10
Thread model: posix

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