[PATCH] D68115: Zero initialize padding in unions

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 15 05:43:06 PST 2020


aaron.ballman added a comment.

In D68115#1820622 <https://reviews.llvm.org/D68115#1820622>, @vitalybuka wrote:

> In D68115#1820579 <https://reviews.llvm.org/D68115#1820579>, @aaron.ballman wrote:
>
> > In D68115#1820462 <https://reviews.llvm.org/D68115#1820462>, @vitalybuka wrote:
> >
> > > I would be happy to finish this patch if we agree on something.
> > >
> > > So if I understand this the proposal is to have something like -fzero-union-padding which is off by default.
> > >  When it's OFF compiler will continue to do whatever it does now.
> > >  When it's ON it will set zeroes into padding with or without -ftrivial-auto-var-init.
> > >  Is this correct?
> >
> >
> > In general, I believe so, yes. To be clear, it only sets zeros into union padding, not *all* padding. I do not have an opinion on whether we want it to be `-fzero-union-padding` as opposed to `-finit-union-padding` that honors the pattern from `-ftrivial-auto-init=pattern` and defaults to zero if no pattern is specified.
>
>
> They whole point of the patch was to avoid breaking code by -ftrivial-auto-init=pattern  with "MyUnion my_union = {}".  So to fix that only `-fzero-union-padding` behavior helpful.
>  `-ftrivial-auto-init=pattern` as-is already inits union padding with patterns.


Ah, okay, good to know!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68115/new/

https://reviews.llvm.org/D68115





More information about the cfe-commits mailing list