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

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I explained this in PR 109945 comment 25

There is no guaranteed copy elision for objects with a trivial copy constructor
and trivial (or deleted) destructor. The compiler is allowed to make temporary
copies, to allow passing the object in registers (which has been what the ABI
requires for decades longer than the guaranteed copy elision rules have
existed).

If you want to have self-referential pointers in your object then you need to
ensure copies really are elided. And so it should not be trivially copyable,
because that removes the guarantee of copy elision.

Reply via email to