diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/tcctest.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/tcctest.c b/tests/tcctest.c index eeabb7c..9598fa4 100644 --- a/tests/tcctest.c +++ b/tests/tcctest.c @@ -2155,6 +2155,8 @@ void c99_vla_test(int size1, int size2) #endif } +typedef __SIZE_TYPE__ uintptr_t; + void sizeof_test(void) { int a; @@ -2175,6 +2177,20 @@ void sizeof_test(void) ptr = NULL; printf("sizeof(**ptr) = %d\n", sizeof (**ptr)); + /* The type of sizeof should be as large as a pointer, actually + it should be size_t. */ + printf("sizeof(sizeof(int) = %d\n", sizeof(sizeof(int))); + uintptr_t t = 1; + uintptr_t t2; + /* Effectively <<32, but defined also on 32bit machines. */ + t <<= 16; + t <<= 16; + t++; + /* This checks that sizeof really can be used to manipulate + uintptr_t objects, without truncation. */ + t2 = t & -sizeof(uintptr_t); + printf ("%lu %lu\n", t, t2); + /* some alignof tests */ printf("__alignof__(int) = %d\n", __alignof__(int)); printf("__alignof__(unsigned int) = %d\n", __alignof__(unsigned int)); |
