I've noticed that clang++ accepts, but g++ rejects: namespace std { template<typename T> struct tuple_size; } struct A { int x, y, z; }; template<> struct std::tuple_size<A> { static const int value = 3; }; constexpr int a = std::tuple_size<A>::value; test.C:3:24: error: specialization of ‘template<class T> struct std::tuple_size’ in different namespace [-fpermissive] template<> struct std::tuple_size<A> { static const int value = 3; }; ^~~~~~~~~~~~~ test.C:1:45: error: from definition of ‘template<class T> struct std::tuple_size’ [-fpermissive] namespace std { template<typename T> struct tuple_size; } ^~~~~~~~~~ Is that a g++ or clang++ bug?
It's invalid in C++98 but valid in C++11, so we should accept it. The change was done by http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3064.pdf to fix http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#374
Fixed. *** This bug has been marked as a duplicate of bug 56480 ***