]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: C++17/20 class layout divergence [PR120012]
authorJason Merrill <jason@redhat.com>
Wed, 30 Apr 2025 14:18:46 +0000 (10:18 -0400)
committerJason Merrill <jason@redhat.com>
Fri, 2 May 2025 11:49:09 +0000 (07:49 -0400)
commite6e3b0772ed40cc65a544bbe744ece62d8b9713e
tree6c392c05fb5a2c57d5145a3a6b84c8735412f284
parent4af5de21363cfdd2be227c05dfdee7e053337f6a
c++: C++17/20 class layout divergence [PR120012]

C++20 made a class with only explicitly defaulted constructors no longer
aggregate, and this wrongly affected whether the class is considered "POD
for layout purposes" under the ABI.

Conveniently, we already have check_non_pod_aggregate to diagnose cases
where this makes a difference, due to PR103681 around a C++14 aggregate
change.

PR c++/120012

gcc/cp/ChangeLog:

* cp-tree.h (struct lang_type): Add non_aggregate_pod.
(CLASSTYPE_NON_AGGREGATE_POD): New.
* class.cc (check_bases_and_members): Set it.
(check_non_pod_aggregate): Diagnose it.

gcc/ChangeLog:

* doc/invoke.texi: Document C++20 aggregate fix.
* common.opt: Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/abi/base-defaulted1.C: New test.
* g++.dg/abi/base-defaulted1a.C: New test.
gcc/common.opt
gcc/cp/class.cc
gcc/cp/cp-tree.h
gcc/doc/invoke.texi
gcc/testsuite/g++.dg/abi/base-defaulted1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/abi/base-defaulted1a.C [new file with mode: 0644]