diff options
-rw-r--r-- | gcc/cp/class.cc | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/abi/no_unique_address2.C | 27 |
2 files changed, 29 insertions, 2 deletions
diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc index e5cc6f1..5db3722 100644 --- a/gcc/cp/class.cc +++ b/gcc/cp/class.cc @@ -6414,8 +6414,8 @@ end_of_class (tree t, eoc_mode mode) { if (mode == eoc_nv_or_dsize) /* For dsize, don't count trailing empty bases. */ - offset = size_binop (PLUS_EXPR, BINFO_OFFSET (binfo), - CLASSTYPE_SIZE_UNIT (BINFO_TYPE (binfo))); + offset = size_binop (PLUS_EXPR, BINFO_OFFSET (base_binfo), + CLASSTYPE_SIZE_UNIT (BINFO_TYPE (base_binfo))); else offset = end_of_base (base_binfo); if (tree_int_cst_lt (result, offset)) diff --git a/gcc/testsuite/g++.dg/abi/no_unique_address2.C b/gcc/testsuite/g++.dg/abi/no_unique_address2.C index bef6d5b..3bb3f76 100644 --- a/gcc/testsuite/g++.dg/abi/no_unique_address2.C +++ b/gcc/testsuite/g++.dg/abi/no_unique_address2.C @@ -41,3 +41,30 @@ struct B4 #define SA(X) static_assert ((X), #X) SA (sizeof (B2) == sizeof (B1)); SA (sizeof (B3) == sizeof (B4)); + +namespace N2 +{ + // C as big as _vptr to test PR c++/104139 + struct C + { + long c; + }; + + struct D: virtual C + { + virtual void f(); + }; + + struct B3: D + { + char c2; + }; + + struct B4 + { + D d [[no_unique_address]]; + char c2; + }; + + SA (sizeof (B3) == sizeof (B4)); +} |