Title
Align new definition of `va_start` with C23
Status
wp
Section
[cstdarg.syn]
Submitter
Jakub Jelinek

Created on 2025-10-01.00:00:00 last changed 1 month ago

Messages

Date: 2025-11-11.10:48:55

Proposed resolution:

This wording is relative to N5014.

  1. Modify [cstdarg.syn] as indicated:

    (1.2) — If more than one argument is present for `va_start` and any of the second or subsequent arguments expands to include unbalanced parentheses, or a preprocessing token that does not convert to a token, the program is ill-formed, no diagnostic required. The preprocessing tokens comprising the second and subsequent arguments to `va_start` (if any) are discarded. [Note 1: `va_start` accepts a second argument for compatibility with prior revisions of C++. — end note]

Date: 2025-11-11.10:48:55

[ Kona 2025-11-08; Status changed: Immediate → WP. ]

Date: 2025-11-06.01:48:06

[ Kona 2025-11-05; approved by LWG. Status changed: New → Immediate. ]

Date: 2025-11-06.01:48:06

[ Kona 2025-11-05; LWG had questions about requiring some cases to be ill-formed. ]

The submitter clarified that it would constrain implementations (effectively requiring `va_start` to be implemented as a magic keyword in the preprocessor, in order to be able to diagnose misuses when preprocessing separately from compilation).

Core approved the new wording.

Date: 2025-10-15.00:00:00

[ 2025-10-14; Reflector poll ]

Set priority to 1 after reflector poll.

Date: 2025-10-01.00:00:00

p3348r4 changed the `va_start` macro to match C23, but the following wording from C is not present in C++:

If any additional arguments expand to include unbalanced parentheses, or a preprocessing token that does not convert to a token, the behavior is undefined.

The importance of that wording was not realized during review of P3348R4. The wording is intended to ensure that any discarded arguments to `va_start` are actually lexable by the compiler, rather than containing unbalanced parentheses or brackets. It also makes the following undefined:

#define BAD ); format_disk(
va_start(ap, BAD);
History
Date User Action Args
2025-11-11 10:48:55adminsetmessages: + msg15678
2025-11-11 10:48:55adminsetstatus: immediate -> wp
2025-11-06 01:48:06adminsetmessages: + msg15539
2025-11-06 01:48:06adminsetmessages: + msg15538
2025-11-06 01:48:06adminsetstatus: new -> immediate
2025-10-14 17:45:42adminsetmessages: + msg15161
2025-10-01 10:01:21adminsetmessages: + msg15094
2025-10-01 00:00:00admincreate