summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr79538.c
blob: 4f10d97395e73af32a8a6fb051eab2b0c03e0313 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* PR middle-end/79538 - missing -Wformat-overflow with %s and non-member array arguments
   { dg-do compile }
   { dg-options "-O2 -Wformat-overflow" } */

char a3[3];
char a4[4];
char d[3];

void g (int i)
{
  const char *s = i < 0 ? a3 : a4;
  __builtin_sprintf (d, "%s", s);      /* { dg-warning ".__builtin_sprintf. may write a terminating nul past the end of the destination" } */
  return;
}

void f ()
{
  char des[3];
  char src[] = "abcd";
  __builtin_sprintf (des, "%s", src); /* { dg-warning "directive writing 4 bytes into a region of size 3" } */
  return;
}