-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
1 parent
f7b2b40
commit 637ce0f
Showing
2 changed files
with
14 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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__); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters