|
| 1 | +<?xml version='1.0' encoding='utf-8' standalone='no'?> |
| 2 | +<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> |
| 3 | + |
| 4 | +<issue num="4388" status="New"> |
| 5 | +<title>Align new definition of `va_start` with C23</title> |
| 6 | +<section><sref ref="[cstdarg.syn]"/></section> |
| 7 | +<submitter>Jakub Jelinek</submitter> |
| 8 | +<date>1 Oct 2025</date> |
| 9 | +<priority>99</priority> |
| 10 | + |
| 11 | +<discussion> |
| 12 | +<p> |
| 13 | +<paper num="p3348r4"/> changed the `va_start` macro to match C23, |
| 14 | +but the following wording from C is not present in C++: |
| 15 | +<blockquote> |
| 16 | +If any additional arguments expand to include unbalanced parentheses, |
| 17 | +or a preprocessing token that does not convert to a token, |
| 18 | +the behavior is undefined. |
| 19 | +</blockquote> |
| 20 | +</p> |
| 21 | +<p> |
| 22 | +The importance of that wording was not realized during review of P3348R4. |
| 23 | +The wording is intended to ensure that any discarded arguments to |
| 24 | +`va_start` are actually lexable by the compiler, |
| 25 | +rather than containing unbalanced parentheses or brackets. |
| 26 | +It also makes the following undefined: |
| 27 | +</p> |
| 28 | +<pre><code>#define BAD ); format_disk( |
| 29 | +va_start(ap, BAD); |
| 30 | +</code></pre> |
| 31 | +</discussion> |
| 32 | + |
| 33 | +<resolution> |
| 34 | +<p> |
| 35 | +This wording is relative to <paper num="N5014"/>. |
| 36 | +</p> |
| 37 | + |
| 38 | +<ul> |
| 39 | +<li><p>Modify <sref ref="[cstdarg.syn]"/> as indicated:</p> |
| 40 | + |
| 41 | +<blockquote> |
| 42 | +<p> |
| 43 | +(1.2) — |
| 44 | +<ins> |
| 45 | +If more than one argument is present for `va_start` |
| 46 | +and any of the second or subsequent arguments expands |
| 47 | +to include unbalanced parentheses, |
| 48 | +or a preprocessing token that does not convert to a token, |
| 49 | +the program is ill-formed, no diagnostic required. |
| 50 | +</ins> |
| 51 | +The preprocessing tokens comprising the second and subsequent arguments to |
| 52 | +`va_start` (if any) are discarded. |
| 53 | +[Note 1: va_start accepts a second argument for compatibility with prior revisions of C++. |
| 54 | +— end note] |
| 55 | +</p> |
| 56 | +</blockquote> |
| 57 | +</li> |
| 58 | +</ul> |
| 59 | + |
| 60 | +</resolution> |
| 61 | + |
| 62 | +</issue> |
0 commit comments