As Kerrek points out in the comment, namespace level const
variables have internal linkage (unless you use the extern
keyword). In C++03 you cannot use the a pointer or reference of a variable with internal linkage as a non-type template argument. That restriction was lifted in C++11. It seems that your version of gcc is playing by the C++03 rules, while the clang compiler is using the C++11 ones.
14.3.2 [temp.arg.nontype] / 1
A template-argument for a non-type, non-template template-parameter shall be one of:
- [...]
- a constant expression (5.19) that designates the address of an object with static storage duration and external or internal linkage or a function with external or internal linkage, including function templates and function template-ids but excluding non-static class members, expressed (ignoring parentheses) as & id-expression, except that the & may be omitted if the name refers to a function or array and shall be omitted if the corresponding template-parameter is a reference; or
- [...]