[PATCH v1] Silence -Wzero-as-null-pointer-constant diagnostics

Joseph Myers josmyers@redhat.com
Fri Nov 15 20:40:02 GMT 2024


On Fri, 15 Nov 2024, Florian Weimer wrote:

> * Alejandro Colomar:
> 
> > Hi Xi,
> >
> > On Fri, Nov 15, 2024 at 08:42:47PM GMT, Xi Ruoyao wrote:
> >> If you want to mean literally "zero-initializing a struct" you should
> >> use {} instead of 0, but doing so is only supported in C23 or as a GNU
> >> extension.
> >
> > Is {} acceptable within glibc's source code?  Or should I take a
> > different approach?
> 
> It's acceptable outside of installed headers.

For structures / unions / arrays, that is.  Scalar initializers {} would 
be problematic because they've only been supported since GCC 13.

-- 
Joseph S. Myers
josmyers@redhat.com



More information about the Libc-alpha mailing list