efriedma-quic wrote:

The only place the standard requires padding to be zero-initialized is in 
"default initialization", which only applies to members which don't have an 
initializer.  So, for example, if you have `struct X { int x; char y; } z = 
{1};`, none of the padding is required to be initialized; the only default 
initialization is of "y", which doesn't have any padding.  Similarly, if you 
have  `union X { char x; int y; } z = {1};`, none of the padding is required to 
be initialized; there's no default initialization at all.  On the other hand, 
if you write `union X { char x; int y; } z = {};`, that padding is required to 
be initialized.

There's probably some argument for doing what this patch does, in addition to 
what the standard requires.  But to avoid any confusion, please file a separate 
bug for that, and make sure the comments in the patch distinguish between what 
the standard requires and what we actually implement.

https://github.com/llvm/llvm-project/pull/97121
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to