This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

4388. Align new definition of va_start with C23

Section: 17.14.2 [cstdarg.syn] Status: New Submitter: Jakub Jelinek Opened: 2025-10-01 Last modified: 2025-10-03

Priority: Not Prioritized

View other active issues in [cstdarg.syn].

View all other issues in [cstdarg.syn].

View all issues with New status.

Discussion:

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);

Proposed resolution:

This wording is relative to N5014.

  1. Modify 17.14.2 [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]