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

--- Comment #3 from Jiang An <de34 at live dot cn> ---
(In reply to Valentine Anderson from comment #2)
> From what I understand, the key feature of trivially copyable types is that
> memcpy‘ing an object of such a type onto another object is equivalent to a
> copy assignment. So it is possible to trivially copy such an object, using
> memcpy.

The current standard wording only guarantees that such copy is OK when the
destination object is already created.

A trivially copyable class is usually also an implicit-lifetime class, so
memcpy is usually sufficient to create that object. But there're also weird
trivially copyable class that is not an implicit-lifetime class (e.g. the class
may have deleted copy/move ctors and trivial assignment operators).

Moreover, it doesn't seem suitable to use memcpy in the cases involved in this
issue...

Reply via email to