[Bug c/107980] va_start incorrectly accepts an arbitrary number of arguments in C2x

aaron at aaronballman dot com gcc-bugzilla@gcc.gnu.org
Mon Dec 5 21:04:31 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107980

--- Comment #2 from Aaron Ballman <aaron at aaronballman dot com> ---
(In reply to Andrew Pinski from comment #1)
> Hmm from https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3054.pdf :
> ```
> 7.16.1.4 The va_start macro
> void va_start(va_list ap, ...);
> 
> 
> Any additional arguments are not used by
> the macro and will not be expanded or evaluated for any reason.
> ```
> 
> 
> I would assume since it is `arguments` rather than additional argument, that
> it could be more than one additional argument.

Yes, the standard says "arguments" because there can be additional arguments
due to using `...`. However, think about the user experience:
```
// This should always be happily accepted because it's
// idiomatic C before C2x and it's valid C in C2x and later.
va_start(list, some_arg);

// This should be accepted in C2x mode and if you care
// to do such things, warn the user that it's incompatible
// with standards before C2x. Pre-C2x, this is an error.
va_start(list);

// Under what circumstances is this anything other than
// programmer confusion? It's invalid before C2x and the
// extra args are meaningless in C2x and later.
va_start(list, 1, 2, 3, 4);
```


More information about the Gcc-bugs mailing list