c++: inherited default constructor [CWG2799]
commit1560cc94e8a6c309a74d0a1a24820087e149733b
authorJason Merrill <jason@redhat.com>
Tue, 19 Sep 2023 02:16:04 +0000 (18 22:16 -0400)
committerJason Merrill <jason@redhat.com>
Tue, 19 Sep 2023 15:28:55 +0000 (19 11:28 -0400)
treef35df570fb8e9f7b69a43b97462fc39437737b15
parentbf6b107e2a342319b3787ec960fc8014ef3aff91
c++: inherited default constructor [CWG2799]

In this testcase, it seems clear that B should be trivially
default-constructible, since the inherited default constructor is trivial
and there are no other subobjects to initialize.  But we were saying no
because we don't define triviality of inherited constructors.

CWG discussion suggested that the solution is to implicitly declare a
default constructor when inheriting a default constructor; that makes sense
to me.

DR 2799

gcc/cp/ChangeLog:

* class.cc (add_implicit_default_ctor): Split out...
(add_implicitly_declared_members): ...from here.
Also call it when inheriting a default ctor.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/inh-ctor38.C: New test.
gcc/cp/class.cc
gcc/testsuite/g++.dg/cpp0x/inh-ctor38.C [new file with mode: 0644]