[Bug c++/66184] New: Rejection of partial specialization of a variable template in a non-global namespace
Casey at Carter dot net
gcc-bugzilla@gcc.gnu.org
Sun May 17 17:53:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66184
Bug ID: 66184
Summary: Rejection of partial specialization of a variable
template in a non-global namespace
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: Casey at Carter dot net
Target Milestone: ---
Created attachment 35558
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35558&action=edit
testcase.cpp
Both 5.1.0 on Wandbox and 6.0 r223061 reject this program:
namespace foo {
template <class, class> constexpr bool same = false;
template <> constexpr bool same<void,void> = true;
template <class T> constexpr bool same<T,T> = true;
static_assert(same<int*,int*>, "");
static_assert(!same<int,int*>, "");
}
int main() {}
with error message:
bug2.cpp:4:35: error: specialization of ‘template<class, class> constexpr const
bool foo::same< <template-parameter-1-1>, <template-parameter-1-2> >’ in
different namespace [-fpermissive]
template <class T> constexpr bool same<T,T> = true;
^
bug2.cpp:2:40: error: from definition of ‘template<class, class> constexpr
const bool foo::same< <template-parameter-1-1>, <template-parameter-1-2> >’
[-fpermissive]
template <class, class> constexpr bool same = false;
^
The full specialization of same<void,void> is accepted regardless of namespace.
Both versions compile the program correctly if "same" is in the global
namespace.
More information about the Gcc-bugs
mailing list