Debian Codegraph @

gcc/testsuite/gcc.dg/c23-tag-composite-10.c

raw
1 /* { dg-do run } */
2 /* { dg-options "-std=c23" } */
3
4 // test padding works correctly
5
6 static struct fo {
7 int a :1;
8 long :3;
9 int b: 1;
10 } x = { };
11
12 static void foo(void* p)
13 {
14 struct fo {
15 int a :1;
16 long :3;
17 int b: 1;
18 } y;
19
20 typeof(*(1 ? &x : &y))* z = p;
21 __builtin_clear_padding(z);
22 }
23
24 int main()
25 {
26 struct fo *p = __builtin_malloc(sizeof *p);
27 __builtin_memset(p, 0xFFFF, sizeof *p);
28 foo(p);
29 p->a = 0;
30 p->b = 0;
31 if (0 != __builtin_memcmp(p, &x, sizeof *p))
32 __builtin_abort();
33 return 0;
34 }
35