On Wed, May 21, 2025 at 01:42:01PM +0100, Christopher Bazley wrote: > On 21/05/2025 12:26, Christopher Bazley wrote: > > Hi Joseph, > > > > Thanks for reviewing my patch. > > > > On 20/05/2025 18:02, Joseph Myers wrote: > > > On Tue, 20 May 2025, Christopher Bazley wrote: > > > > > > > + if (!cleared) > > > > + { > > > > + if (complete_p.padded_non_union > > > > + && warn_zero_init_padding_bits >= ZERO_INIT_PADDING_BITS_ALL) > > > > + { > > > > + warning (OPT_Wzero_init_padding_bits_, > > > > + "Padding bits might not be initialized to zero; " > > > > + "consider using %<-fzero-init-padding-bits=all%>"); > > > > + } > > > > + else if (complete_p.padded_union > > > > + && warn_zero_init_padding_bits > > > > + >= ZERO_INIT_PADDING_BITS_UNIONS) > > > > + { > > > > + warning (OPT_Wzero_init_padding_bits_, > > > > + "Padding bits might not be initialized to zero; " > > > > + "consider using %<-fzero-init-padding-bits=unions%> " > > > > + "or %<-fzero-init-padding-bits=all%>"); > > > Diagnostics should start with a lowercase letter. > > > > I'll change it to "padding might not be initialized to zero..." OK? > > > > ("padding" seems to be more common than "padding bits" in existing > > messages.) > > > > Is there anything I need to do for initialization? > > Sorry, I meant "internationalisation" (i.e. to support translation), not > "initialization"!
For translations I think it is fine as is. Please avoid {}s around single statements (e.g. the warning call above). And, I think the warnings should include text like "if code relies on it being zero, consider" because telling people to use those options mindlessly is undesirable. Having uninitialized padding bits is most of the time just fine, only if code accesses it (whether writing it to disk, or say computing checksum of all the bytes in it etc.), it is problematic. And there are many other cases where nothing warns about those. struct S { char a; long long b; }; void bar (struct S *); void foo () { struct S a = { 1, 2 }; // Here you'd warn? struct S b; // Here I'm sure you wouldn't. b.a = 1; b.b = 2; bar (&a, &b); } Jakub