1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <stddef.h>
11
12 #include <stddef.h>
13 #include <cassert>
14 #include <type_traits>
15
16 #include "test_macros.h"
17
18 #ifndef NULL
19 #error NULL not defined
20 #endif
21
22 #ifndef offsetof
23 #error offsetof not defined
24 #endif
25
main()26 int main()
27 {
28 void *p = NULL;
29 assert(!p);
30
31 static_assert(sizeof(size_t) == sizeof(void*),
32 "sizeof(size_t) == sizeof(void*)");
33 static_assert(std::is_unsigned<size_t>::value,
34 "std::is_unsigned<size_t>::value");
35 static_assert(std::is_integral<size_t>::value,
36 "std::is_integral<size_t>::value");
37 static_assert(sizeof(ptrdiff_t) == sizeof(void*),
38 "sizeof(ptrdiff_t) == sizeof(void*)");
39 static_assert(std::is_signed<ptrdiff_t>::value,
40 "std::is_signed<ptrdiff_t>::value");
41 static_assert(std::is_integral<ptrdiff_t>::value,
42 "std::is_integral<ptrdiff_t>::value");
43 static_assert((std::is_same<decltype(nullptr), nullptr_t>::value),
44 "decltype(nullptr) == nullptr_t");
45 static_assert(sizeof(nullptr_t) == sizeof(void*),
46 "sizeof(nullptr_t) == sizeof(void*)");
47 #if TEST_STD_VER > 17
48 // P0767
49 static_assert(std::is_trivial<max_align_t>::value,
50 "std::is_trivial<max_align_t>::value");
51 static_assert(std::is_standard_layout<max_align_t>::value,
52 "std::is_standard_layout<max_align_t>::value");
53 #else
54 static_assert(std::is_pod<max_align_t>::value,
55 "std::is_pod<max_align_t>::value");
56 #endif
57 static_assert((std::alignment_of<max_align_t>::value >=
58 std::alignment_of<long long>::value),
59 "std::alignment_of<max_align_t>::value >= "
60 "std::alignment_of<long long>::value");
61 static_assert(std::alignment_of<max_align_t>::value >=
62 std::alignment_of<long double>::value,
63 "std::alignment_of<max_align_t>::value >= "
64 "std::alignment_of<long double>::value");
65 static_assert(std::alignment_of<max_align_t>::value >=
66 std::alignment_of<void*>::value,
67 "std::alignment_of<max_align_t>::value >= "
68 "std::alignment_of<void*>::value");
69 }
70