gcc/testsuite/gcc.dg/pr79222.c
raw| 1 | /* PR middle-end/79222 - missing -Wstringop-overflow= on a stpcpy overflow |
| 2 | { dg-do compile } |
| 3 | { dg-options "-O2" } */ |
| 4 | |
| 5 | extern char* stpcpy (char*, const char*); |
| 6 | |
| 7 | char d[3]; |
| 8 | |
| 9 | char* f (int i) |
| 10 | { |
| 11 | const char *s = i < 0 ? "01234567" : "9876543210"; |
| 12 | return stpcpy (d, s); /* { dg-warning ".stpcpy. writing between 9 and 11 bytes into a region of size 3 overflows the destination" } */ |
| 13 | } |