1 /* Verify that casts between pointers and integers don't trigger false
2 positives. Test derived from Glibc's _dl_allocate_tls_storage() in
3 dl-tls.c.
4 { dg-do compile }
5 { dg-options "-O2 -Wall -Wno-array-bounds" } */
6
7 typedef __SIZE_TYPE__ size_t;
8 typedef __UINTPTR_TYPE__ uintptr_t;
9
10 size_t a;
11 size_t s;
12
13 void* _dl_allocate_tls_storage (void)
14 {
15 void *p = __builtin_malloc (s + a + sizeof (void *));
16
17 char *q = (char *)(__builtin_constant_p (a) && (((a - 1) & a) == 0)
18 ? ((((uintptr_t)p) + a - 1) & ~(a - 1))
19 : (((((uintptr_t)p) + (a - 1)) / a) * a));
20
21 char *r = q + s - sizeof (int[4]);
22 __builtin_memset (r, '\0', sizeof (int[4]));
23 return r;
24 }