https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107980
Bug ID: 107980
Summary: va_start incorrectly accepts an arbitrary number of
arguments in C2x
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: aaron at aaronballman dot com
Target Milestone: ---
GCC implemented WG14 N2975 which relaxes the requirements for va_start.
However, there's a diagnostic missing for it when the user passes more than two
arguments:
```
#include <stdarg.h>
void func(int i, ...) {
va_list va;
va_start(va, i, 23, 4);
va_end(va);
}
```
is silently accepted by GCC even with -Wall and -pedantic.
I noticed this when I was working on the Clang implementation of N2975. I
noticed that GCC has not changed the definition of __builtin_va_start, which I
think is a good approach (keeping builtin interfaces stable between compiler
and language versions is a nicety). I was considering adding
`__builtin_c23_va_start` to Clang with a signature that accepts `...` so I can
diagnose this case, but I think that will run afoul of 7.16.1.4p4 "Any
additional arguments are not used by the macro and will not be expanded or
evaluated for any reason." without some heroics, so I'm not certain how/if
Clang will address this.