Skip to content

Null pointer not accepted as non-type template argument #10072

@llvmbot

Description

@llvmbot
Bugzilla Link 9700
Resolution FIXED
Resolved on Apr 06, 2012 17:41
Version unspecified
OS MacOS X
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@RealLitb

Extended Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++11

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions