Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.dg / Wstringop-overflow-32.c
blobe5939567a4ded4b0b3e63273247a346b9335b006
1 /* PR middle-end/93829 - bogus -Wstringop-overflow on memcpy of a struct
2 with a pointer member from another with a long string
3 { dg-do compile }
4 { dg-options "-O2 -Wall" } */
6 extern void* memcpy (void*, const void*, __SIZE_TYPE__);
8 #define S40 "0123456789012345678901234567890123456789"
10 const char s40[] = S40;
12 struct S
14 const void *p, *q, *r;
15 } s, sa[2];
18 void test_lit_decl (void)
20 struct S t = { 0, S40, 0 };
22 memcpy (&s, &t, sizeof t); // { dg-bogus "-Wstringop-overflow" }
25 void test_str_decl (void)
27 struct S t = { 0, s40, 0 };
29 memcpy (&s, &t, sizeof t); // { dg-bogus "-Wstringop-overflow" }
33 void test_lit_ssa (int i)
35 if (i < 1)
36 i = 1;
37 struct S *p = &sa[i];
38 struct S t = { 0, S40, 0 };
40 memcpy (p, &t, sizeof t); // { dg-bogus "-Wstringop-overflow" }
43 void test_str_ssa (int i)
45 if (i < 1)
46 i = 1;
47 struct S *p = &sa[i];
48 struct S t = { 0, s40, 0 };
50 memcpy (p, &t, sizeof t); // { dg-bogus "-Wstringop-overflow" }