Skip to content

[C2y] Add documentation to conform to WG14 N3262; NFC #98146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion clang/docs/LanguageExtensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3977,7 +3977,10 @@ standard library ``<stdarg.h>`` header:

* ``__builtin_va_list``

A predefined typedef for the target-specific ``va_list`` type.
A predefined typedef for the target-specific ``va_list`` type. It is undefined
behavior to use a byte-wise copy of this type produced by calling ``memcpy``,
``memmove``, or similar. Valid explicit copies are only produced by calling
``va_copy`` or ``__builtin_va_copy``.

* ``void __builtin_va_start(__builtin_va_list list, <parameter-name>)``

Expand Down
20 changes: 20 additions & 0 deletions clang/test/C/C2y/n3262.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// RUN: %clang_cc1 -verify -std=c2y -Wall -pedantic %s
// expected-no-diagnostics

/* WG14 N3262: Yes
* Usability of a byte-wise copy of va_list
*
* NB: Clang explicitly documents this as being undefined behavior. A
* diagnostic is produced for some targets but not for others for assignment or
* initialization, but no diagnostic is possible to produce for use with memcpy
* in the general case, nor with a manual bytewise copy via a for loop.
*
* Therefore, nothing is tested in this file; it serves as a reminder that we
* validated our documentation against the paper. See
* clang/docs/LanguageExtensions.rst for more details.
*
* FIXME: it would be nice to add ubsan support for recognizing when an invalid
* copy is made and diagnosing on copy (or on use of the copied va_list).
*/

int main() {}
2 changes: 1 addition & 1 deletion clang/www/c_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@ <h2 id="c2y">C2y implementation status</h2>
<tr>
<td>Usability of a byte-wise copy of va_list</td>
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3262.pdf">N3262</a></td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Yes</td>
</tr>
<tr>
<td>alignof of an incomplete array type</td>
Expand Down
Loading