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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Giuseppe D'Angelo from comment #2)
> By the way: while reducing this example, I've noted that if one uses `VLA()
> {}`, then the byte-filling gets disabled. Is it intended? It's not exactly
> discussed
> https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-ftrivial-auto-
> var-init , and I guess could be an acceptable workaround.

Since that makes the class non-trivially-default-constructible, I think it
matches the expectation that the option only affects *trivial* automatic
variables.

And it's also consistent with preventing zero-init of all members and padding
bits when a VLA object is value-initialized.

But despite that workaround, I still think this is a reasonable extension to
the meaning of the attribute.

A class can define constructors and accessors that maintain an invariant that
the data member is not accessed while uninitialized, so it seems reasonable to
be able to prevent the auto-initialization by annotating the data member.

Reply via email to