https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127249
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|15.3.1 |17.0
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Same problem when the mem-initializer is invalid for other reasons:
template<typename T, typename... U>
struct Foo /* : T */ // oops, forgot the base class
{
int inner;
Foo() : T(), inner() { }
};
struct X { };
int main()
{
Foo<X> f;
}
GCC says:
def.cc: In instantiation of 'Foo<T, U>::Foo() [with T = X; U = {}]':
def.cc:13:10: required from here
13 | Foo<X> f;
| ^
def.cc:6:22: error: type 'X' is not a direct base of 'Foo<X>'
6 | Foo() : T(), inner() { }
| ^
Clang says:
def.cc:6:11: error: type 'X' is not a direct or virtual base of 'Foo<X>'
6 | Foo() : T(), inner() { }
| ^
def.cc:13:10: note: in instantiation of member function 'Foo<X>::Foo' requested
here
13 | Foo<X> f;
| ^
1 error generated.
and EDG says:
"def.cc", line 6: error: "T" is not a nonstatic data member or base class of
class "Foo<X>"
Foo() : T(), inner() { }
^
detected during instantiation of "Foo<T, U...>::Foo() [with T=X,
U=<>]" at line 13
1 error detected in the compilation of "def.cc".