| 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" } */ |
| 4 |
|
| 5 |
char a3[3]; |
| 6 |
char a4[4]; |
| 7 |
char d[3]; |
| 8 |
|
| 9 |
void g (int i) |
| 10 |
{ |
| 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; |
| 14 |
} |
| 15 |
|
| 16 |
void f () |
| 17 |
{ |
| 18 |
char des[3]; |
| 19 |
char src[] = "abcd"; |
| 20 |
__builtin_sprintf (des, "%s", src); /* { dg-warning "directive writing 4 bytes into a region of size 3" } */ |
| 21 |
return; |
| 22 |
} |