[PATCH v3 2/7] malloc/obstack.h: Assume GCC supports __extension__
Joseph Myers
josmyers@redhat.com
Tue Nov 11 16:55:14 GMT 2025
On Tue, 11 Nov 2025, Alejandro Colomar wrote:
> > * a stdarg.h that defines va_list
>
> The relevant change is:
>
> #if defined __USE_XOPEN2K || defined __USE_XOPEN2K8
> -# ifdef __GNUC__
> -# ifndef _VA_LIST_DEFINED
> -typedef __gnuc_va_list va_list;
> -# define _VA_LIST_DEFINED
> -# endif
> -# else
> +# ifndef __GNUC__
> # include <stdarg.h>
> # endif
> #endif
>
> I'm only changing the assumption if __GNUC__ is defined. This change
> assumes that GCC provides va_list in its own header. However, I'm not
> changing any assumptions for non-__GNUC__ compilers.
I think this change (to <stdio.h>) is actually incorrect for modern GCC
(indeed, I don't see how the patched glibc would have passed the conform/
tests).
Early on, the header does:
#define __need___va_list
#include <stdarg.h>
The point of that is, if the __need_* protocol is working correctly, to
define __gnuc_va_list but *not* va_list (because ISO C, for example, does
not allow <stdio.h> to define va_list, despite having interfaces such as
vprintf that involve va_list in their types). So with GCC, or compatible
compilers, __gnuc_va_list will be defined, but not va_list - unless the
user had previously included <stdarg.h> themself without __need___va_list
defined.
But then there is the POSIX requirement (CX-tagged in the 2008 and 2024
editions, XSI-tagged in the 2004 edition) to define va_list in <stdio.h>.
That's what the code you're changing implements. And your change would
cause <stdio.h> to fail to implement that requirement with current GCC.
--
Joseph S. Myers
josmyers@redhat.com
More information about the Libc-alpha
mailing list