Skip to content

Commit

Permalink
[C2x] Claim support for WG14 N2838
Browse files Browse the repository at this point in the history
This paper clarifies that complete object types need to be smaller than
SIZE_MAX. We already conformed to that requirement, so this adds some
test coverage to prove it.
  • Loading branch information
AaronBallman committed Mar 3, 2023
1 parent f7b2b40 commit 637ce0f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions clang/test/C/C2x/n2838.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// RUN: %clang_cc1 -verify -std=c2x %s

/* WG14 N2838: yes
* Types and sizes
*/

char buffer4[0xFFFF'FFFF'FFFF'FFFF'1wb]; /* expected-error {{array is too large (295147905179352825841 elements)}} */
char buffer3[0xFFFF'FFFF'FFFF'FFFFwb]; /* expected-error {{array is too large (18446744073709551615 elements)}} */
char buffer2[0x7FFF'FFFF'FFFF'FFFFwb]; /* expected-error {{array is too large (9223372036854775807 elements)}} */
char buffer1[0x1FFF'FFFF'FFFF'FFFFwb]; /* array is juuuuuust right */

/* The largest object we can create is still smaller than SIZE_MAX. */
static_assert(0x1FFF'FFFF'FFFF'FFFFwb <= __SIZE_MAX__);
2 changes: 1 addition & 1 deletion clang/www/c_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ <h2 id="c2x">C2x implementation status</h2>
<tr>
<td>Types and sizes</td>
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2838.htm">N2838</a></td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Yes</td>
</tr>
<tr>
<td>Clarifying integer terms</td>
Expand Down

0 comments on commit 637ce0f

Please sign in to comment.