[Bug c++/88417] partial specialization of static template variable inside class template gives wrong result

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Aug 23 09:50:38 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88417

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reduced self contained testcase:
extern "C" int printf(const char*,...);
extern "C" void abort();
 template < typename T>
struct X
{
    int i;
    constexpr X(int _i): i{_i}{}
};
template < typename T2 >
struct Y
{
    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()
{
    if (Y<bool>::x_in_y<float>.i != 77)
    abort();
}


More information about the Gcc-bugs mailing list