Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/gcc.dg/Wstringop-overflow-32.c @ 158:494b0b89df80 default tip
...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 25 May 2020 18:13:55 +0900 |
parents | 2b5abeee2509 |
children |
line wrap: on
line source
/* PR middle-end/93829 - bogus -Wstringop-overflow on memcpy of a struct with a pointer member from another with a long string { dg-do compile } { dg-options "-O2 -Wall" } */ extern void* memcpy (void*, const void*, __SIZE_TYPE__); #define S40 "0123456789012345678901234567890123456789" const char s40[] = S40; struct S { const void *p, *q, *r; } s, sa[2]; void test_lit_decl (void) { struct S t = { 0, S40, 0 }; memcpy (&s, &t, sizeof t); // { dg-bogus "-Wstringop-overflow" } } void test_str_decl (void) { struct S t = { 0, s40, 0 }; memcpy (&s, &t, sizeof t); // { dg-bogus "-Wstringop-overflow" } } void test_lit_ssa (int i) { if (i < 1) i = 1; struct S *p = &sa[i]; struct S t = { 0, S40, 0 }; memcpy (p, &t, sizeof t); // { dg-bogus "-Wstringop-overflow" } } void test_str_ssa (int i) { if (i < 1) i = 1; struct S *p = &sa[i]; struct S t = { 0, s40, 0 }; memcpy (p, &t, sizeof t); // { dg-bogus "-Wstringop-overflow" } }