[Bug c++/88417] New: partial specialization of static template variable inside class template gives wrong result
lts-rudolph at gmx dot de
gcc-bugzilla@gcc.gnu.org
Sat Dec 8 23:17:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88417
Bug ID: 88417
Summary: partial specialization of static template variable
inside class template gives wrong result
Product: gcc
Version: 8.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: lts-rudolph at gmx dot de
Target Milestone: ---
If I do a partial template variable specialization inside a template class I
got the wrong results and/or if no unspecialised version is provided I got a
linker error.
template < typename T>
class X
{
public:
T i;
X(T _i): i{_i}{}
operator T(){ return i; }
};
template < typename T2 >
class Y
{
public:
template <typename T>
static X<T> x_in_y;
};
template< typename T2>
template< typename T>
X<T> Y<T2>::x_in_y{200};
template<>
template<>
X<float> Y<int>::x_in_y<float>{100};
template<>
template<>
X<int> Y<int>::x_in_y<int>{101};
// this partial specialization is never seen, but compiles without error
template< >
template< typename T >
X<T> Y<bool>::x_in_y{77};
int main()
{
std::cout << Y<int>::x_in_y<int> << std::endl;
std::cout << Y<int>::x_in_y<float> << std::endl;
std::cout << Y<float>::x_in_y<float> << std::endl;
std::cout << Y<bool>::x_in_y<float> << std::endl;
}
expected result:
101
100
200
77
More information about the Gcc-bugs
mailing list