On Fri, Jan 24, 2025 at 08:48:45AM +0100, Morten Brørup wrote:
> > From: Stephen Hemminger [mailto:step...@networkplumber.org]
> > Sent: Thursday, 23 January 2025 18.21
> > 
> > With GCC 15, the compiler has changed the default behavior when
> > initialization is used for aggregate variables. The new default
> > is to follow the standard (C23) and not initialize everything by
> > default. This breaks assumptions in some drivers and can be
> > lead to other bugs.
> > 
> > Use the new zero initialization flag to force the old behavior
> > of initializing everything to zero.
> > 
> > Signed-off-by: Stephen Hemminger <step...@networkplumber.org>
> > ---
> >  config/meson.build | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/config/meson.build b/config/meson.build
> > index 6aaad6d8a4..5c8b5a15f5 100644
> > --- a/config/meson.build
> > +++ b/config/meson.build
> > @@ -330,6 +330,9 @@ warning_flags = [
> 
> Is warning_flags the right location for this?
> Alternatively, should warning_flags be renamed?
> 

+1 to renaming warning flags, to e.g. "global_cflags"?

> >          # globally disabled warnings
> >          '-Wno-packed-not-aligned',
> >          '-Wno-missing-field-initializers',
> > +
> > +        # guarantee that everything is zero when using initialization
> 
> Maybe add ", like in the C23 standard" to the comment.
> 
> > +        '-fzero-init-padding-bits=all',
> >  ]
> > 
> >  if not dpdk_conf.get('RTE_ARCH_64')
> > --
> > 2.45.2
> 
> I have read up on -fzero-init-padding-bits, and this is the correct solution.
> 

Does this flag give us additional guarantees of padding being
zero-initialized that were there before? From my reading of the gcc doc[1],
"..padding-bits=union" corresponds to the old behaviour, right?

This also means we will have different padding behaviour on clang and gcc,
since clang (at least v18 on my board) doesn't support this flag. Do we see
any issues with that?

/Bruce

[1] https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html
> With or without suggested changes:
> Acked-by: Morten Brørup <m...@smartsharesystems.com>
> 

Reply via email to