[Bug c++/71569] [6/7/8 regression] Crash: External definition of template member from template struct
oliver.tale at web dot de
gcc-bugzilla@gcc.gnu.org
Thu Mar 1 15:15:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71569
--- Comment #6 from Oliver Tale-Yazdi <oliver.tale at web dot de> ---
It seems to be only dependent on the template specialization of the member.
–––––––––––––––––––––––––––––––––––––––––––––––––––
template <class T>
struct A {
template <class U>
static U u;
};
template <class T>
template <class U>
U A<T>::u = nullptr;
–––––––––––––––––––––––––––––––––––––––––––––––––––
template <class T>
struct A {
template <class U>
static U u;
};
template <class T>
template <class U>
U A<T>::u<U*> = nullptr;
–––––––––––––––––––––––––––––––––––––––––––––––––––
The first one is accepted, the second one ICE's. Both is valid C++14.
I also need to point out that >= 5.1 accepts weird (invalid?) Code, eg:
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
#include <iostream>
template <class T>
struct A {
template <class U>
static U u;
};
template <class T>
template <class U>
U A<T>::u = nullptr;
int main()
{
std::cerr << "'" << typeid(decltype(A<int>::u)).name() << "'" << std::endl;
}
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
This dosent print _Anything_.
I dont even have to include <typeinfo>, which is needed, if I specialize u with
A<int>::u<int> in the second last line.
typeid seems to not be called.
More information about the Gcc-bugs
mailing list