[Bug c++/89898] invalid function template definition with non-type class argument accepted
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Aug 26 21:09:41 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89898
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is valid C++ 20 too:
struct A { int t; };
template <A a> struct X { int d = a.t; };
template<X<A{}> a > int f () { return a.d; }
int g(void)
{
return f<X<A{0}>{1}>();
}
Yes I know it looks off but it is valid now and f<<X<A{0}>{1}> will return 1.
Note {} and {0} are the same here really.
Even something like this is valid now too:
struct A { int t; };
template <A a> struct X { int d = a.t; };
template<A a, X<a> x > int f () { return x.d; }
int g(void)
{
return f<A{2}, X<A{2}>{1}>();
}
More information about the Gcc-bugs
mailing list