]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Correct behaviour of layout_compatible_type for aligned types
authorNathaniel Shead <nathanieloshead@gmail.com>
Sat, 22 Nov 2025 11:11:35 +0000 (22:11 +1100)
committerNathaniel Shead <nathanieloshead@gmail.com>
Sat, 22 Nov 2025 23:45:08 +0000 (10:45 +1100)
commit59cf3fa79caa945a99fdc3b5bd349987fd23dd92
tree5965fd8977837560684299875c150c73474f7851
parent70789a03fb337d967e57b25c56d1097fff5952e6
c++: Correct behaviour of layout_compatible_type for aligned types

The standard does not require two types to have the same alignment (and
hence size) to be considered layout-compatible.  The same applies to
members of unions.

gcc/cp/ChangeLog:

* typeck.cc (layout_compatible_type_p): Do not check TYPE_SIZE.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/is-layout-compatible3.C: Adjust expected results.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/typeck.cc
gcc/testsuite/g++.dg/cpp2a/is-layout-compatible3.C