C++ Logo

liaison

Advanced search

Re: [isocpp-wg14/wg21-liaison] Extra arguments to va_start

From: Joseph Myers <josmyers_at_[hidden]>
Date: Wed, 12 Nov 2025 21:46:59 +0000 (UTC)
On Wed, 12 Nov 2025, Jens Maurer via Liaison wrote:

> There are three levels of ignored:
>
> (1) preprocessing tokens are ignored (__COUNTER__ is not incremented):
>
> #define va_start(list, ...) __builtin_va_start(list)

I think this is supposed to be allowed in C23.

>
> (2) tokens are ignored (__COUNTER__ is incremented, no phase 7 name lookup):
>
> #define va_start(list, ...) __builtin_va_start(list, __VA_ARGS__ ???)

And I think this is supposed to be allowed in C23 if __builtin_va_start is
handled specially as syntax in the compiler to discard second and
subsequent arguments (possibly after diagnosing them if they seem
suspicious). That's the point of having undefined behavior for unbalanced
parentheses or preprocessing tokens that do not convert to tokens: if the
arguments expand to involve either of those, the compiler, taking the
sequence of tokens received from the preprocessor, can no longer reliably
tell where the arguments to va_start end (or, in the case of preprocessing
tokens not converting to tokens, failure occurs at an earlier stage).
Only special syntactic handling in the compiler is needed to produce
diagnostics using this approach, not anything special in the preprocessor.

-- 
Joseph S. Myers
josmyers_at_[hidden]

Received on 2025-11-12 21:47:06