https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63374
Bug ID: 63374
Summary: unhelpful diagnostics for missing initializer
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: manu at gcc dot gnu.org
class B {
public:
B(int x) : z(x) {}
int z;
};
class A {
public:
B b1;
int a1;
B b2;
int a2;
B b3;
int b4;
B a4;
A(int x) : b1(x), b2(x), b3(x), b4(x) {}
};
manuel@gcc10:~$ ~/test1/214251/build/gcc/cc1plus test.cc
B::B(int) B::B(int) B::B(int) A::A(int)
test.cc:16:39: error: no matching function for call to ‘B::B()’
A(int x) : b1(x), b2(x), b3(x), b4(x) {}
^
test.cc:3:3: note: candidate: B::B(int)
B(int x) : z(x) {}
^
test.cc:3:3: note: candidate expects 1 argument, 0 provided
test.cc:1:7: note: candidate: B::B(const B&)
class B {
^
test.cc:1:7: note: candidate expects 1 argument, 0 provided
manuel@gcc10:~$ clang++ test.cc
test.cc:16:3: error: constructor for 'A' must explicitly initialize the member
'a4' which does not have a default constructor
A(int x) : b1(x), b2(x), b3(x), b4(x) {}
^
test.cc:14:5: note: member is declared here
B a4;
^
test.cc:1:7: note: 'B' declared here
class B {
^
1 error generated.