libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / Wstringop-overflow-21-novec.c
blob6f83548e902346ab77e1527363eb9da46d20fe6c
1 /* PR middle-end/92312 - bogus -Wstringop-overflow storing into a trailing
2 array backed by larger buffer
3 { dg-do compile }
4 { dg-options "-O2 -fno-tree-vectorize -Wall -Wno-array-bounds" } */
6 struct S0 { char a, b[0]; };
8 void sink (void*);
10 void test_store_zero_length (int i)
12 char a[3];
13 struct S0 *p = (struct S0*)a;
14 p->a = 0;
15 p->b[0] = 0;
16 p->b[1] = 1; // { dg-bogus "\\\[-Wstringop-overflow" }
17 p->b[2] = 2; // { dg-warning "\\\[-Wstringop-overflow" }
18 p->b[i] = 2;
19 sink (p);
22 struct Sx { char a, b[]; };
24 void test_store_flexarray (int i)
26 char a[3];
27 struct Sx *p = (struct Sx*)a;
28 p->a = 0;
29 p->b[0] = 0;
30 p->b[1] = 1; // { dg-bogus "\\\[-Wstringop-overflow" }
31 p->b[2] = 1; // { dg-warning "\\\[-Wstringop-overflow" }
32 p->b[i] = 2;
33 sink (p);