diff options
author | Martin Sebor <msebor@redhat.com> | 2019-12-11 15:59:55 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2019-12-11 08:59:55 -0700 |
commit | 0a22f996399c968efe9bfec96bd9f87ee537be12 (patch) | |
tree | 087207ac8a6db778d9ea4ee609b64f121d866f60 /gcc/testsuite/gcc.dg/Wstringop-overflow-26.c | |
parent | ddd0fd173a12111f9cb6747d7714b976f870c70b (diff) | |
download | gcc-0a22f996399c968efe9bfec96bd9f87ee537be12.zip gcc-0a22f996399c968efe9bfec96bd9f87ee537be12.tar.gz gcc-0a22f996399c968efe9bfec96bd9f87ee537be12.tar.bz2 |
PR middle-end/79221 - missing -Wstringop-overflow= on a strcat overflow
gcc/testsuite/ChangeLog:
* gcc.dg/Wstringop-overflow-26.c: New test.
From-SVN: r279227
Diffstat (limited to 'gcc/testsuite/gcc.dg/Wstringop-overflow-26.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/Wstringop-overflow-26.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-26.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-26.c new file mode 100644 index 0000000..4e8765e --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-26.c @@ -0,0 +1,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" } +} |