summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/Wstringop-overflow-26.c
blob: 4e8765eedbb8058abceb4dd5f731344589408867 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* PR middle-end/79221 - missing -Wstringop-overflow= on a strcat overflow
   { dg-do compile }
   { dg-options "-O2 -Wall" } */

extern char* strcat (char*, const char*);

char d[3];

void f (int i)
{
  const char *s = i < 0 ? "01234567" : "89abcd";
  strcat (d, s);    // { dg-warning "'strcat' writing between 7 and 9 bytes into a region of size 3" } */
}


void g (int i)
{
  const char *s = i < 0 ? "12345678" : "87654321";
  strcat (d, s);    // { dg-warning "\\\[-Warray-bounds|-Wstringop-overflow" }
}