PR middle-end/97631 - bogus "writing one too many bytes" warning for memcpy with...
authorMartin Sebor <msebor@redhat.com>
Mon, 8 Mar 2021 20:28:52 +0000 (13:28 -0700)
committerMartin Sebor <msebor@redhat.com>
Mon, 8 Mar 2021 20:28:52 +0000 (13:28 -0700)
commit7f5ff78ff3f971c11ec67f422b2fd34281db9123
treeb7458cb5524353d63a17efea75f21868f8259978
parentb64551af5159ea30b5941ddd430001b13936822c
PR middle-end/97631 - bogus "writing one too many bytes" warning for memcpy with strlen argument

gcc/ChangeLog:

PR middle-end/97631
* tree-ssa-strlen.c (maybe_warn_overflow): Test rawmem.
(handle_builtin_stxncpy_strncat): Rename locals.  Determine
destination size from allocation calls.  Issue a more appropriate
kind of warning.
(handle_builtin_memcpy): Pass true as rawmem to maybe_warn_overflow.
(handle_builtin_memset): Same.

gcc/testsuite/ChangeLog:

PR middle-end/97631
* c-c++-common/Wstringop-overflow.c: Remove unexpected warnings.
Add an xfail.
* c-c++-common/Wstringop-truncation.c: Add expected warnings.
* gcc.dg/Wstringop-overflow-10.c: Also enable -Wstringop-truncation.
* gcc.dg/Wstringop-overflow-66.c: New test.
* gcc.dg/tree-ssa/strncpy-2.c: Adjust expected warning.
gcc/testsuite/c-c++-common/Wstringop-overflow.c
gcc/testsuite/c-c++-common/Wstringop-truncation.c
gcc/testsuite/gcc.dg/Wstringop-overflow-10.c
gcc/testsuite/gcc.dg/Wstringop-overflow-66.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/strncpy-2.c
gcc/tree-ssa-strlen.c