PR middle-end/85602 - -Wsizeof-pointer-memaccess for strncat with size of source
[official-gcc.git] / gcc / testsuite / gcc.dg / pr79538.c
blob6cdab45128afdc3672a4cdcb7ccd6c2d46082ec4
1 /* PR middle-end/79538 - missing -Wformat-overflow with %s and non-member array arguments
2 { dg-do compile }
3 { dg-options "-O2 -Wformat-overflow" } */
5 char a3[3];
6 char a4[4];
7 char d[3];
9 void g (int i)
11 const char *s = i < 0 ? a3 : a4;
12 __builtin_sprintf (d, "%s", s); /* { dg-warning ".__builtin_sprintf. may write a terminating nul past the end of the destination" } */
13 return;
16 void f ()
18 char des[3];
19 char src[] = "abcd";
20 __builtin_sprintf (des, "%s", src); /* { dg-warning "directive writing up to 4 bytes into a region of size 3" } */
21 return;