[Bug c++/93916] Implicit copy/assignment alters padding bits of storage

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Feb 25 11:15:00 GMT 2020


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

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to andysem from comment #4)
> Are you saying that implementation is allowed to not preserve unused storage
> state upon construction and assignment? Because I don't think this is what
> the standard says.

I disagree. It doesn't say the values of padding bits are preserved after
constructing an object in that storage.

> Is there any other way to achieve the effect of initializing padding in a
> struct?

The standard requires zero-initialization to clear all padding bits. Other
forms of initialization (including copy-initialization as in your example) do
not specify the effect on padding bits.


More information about the Gcc-bugs mailing list