https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87521

James Y Knight <foom at fuhm dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |foom at fuhm dot net

--- Comment #5 from James Y Knight <foom at fuhm dot net> ---
Since it's effectively arbitrary whether to allow tail padding or not, and the
ABI doesn't actually say, it's not actually possible to say that gcc's behavior
is "correct".

The only way to actually resolve this is to fix the ABI to say what to do. It
already has an open issue: https://github.com/itanium-cxx-abi/cxx-abi/issues/66

(The current thinking there is to require GCC's current implementation, AIUI.)


Regarding comment #3: that doesn't prove anything -- it's entirely possible
(not indicative of a bug) for a struct to be both trivially_copyable and not
pod-for-layout.

Your test-case is not valid, per [basic.types] para 3 -- which requires that
the trivially_copyable type not be a base-class subobject in order for
memcpy'ing the bytes to be valid. (The Itanium ABI also notes this.)

And, for example, if you changed the code:
-struct Base {
+struct ReallyBase {};
+struct Base : public ReallyBase {

then GCC also "fails that test" -- Base is now unambiguously not POD-for-layout
since it has a base class, but it is still trivially_copyable.

Reply via email to