On Mon, 2020-02-10 at 15:47 -0700, Martin Sebor wrote: > The reporter of RHBZ #1798636 was mislead and confused by GCC > issuing -Wstringop-truncation for a possible overflow in strncat. > It took a few iterations to appreciate this subtlety and realize > the warning was of the wrong kind. > > The attached patch adjusts the logic of the function responsible > for the warning not to issue -Wstringop-truncation only for strncpy > and -Wstringop-overflow for strncat. > > I'm not sure if the bug is strictly speaking a regression: GCC 8 > didn't issue any warning so it could be viewed as one, but then > again, issuing a warning in this instance is intended, but not > a misleading one. > > Tested on x86_64-linux. > > Martin > PR middle-end/93646 - confusing -Wstringop-truncation on strncat where > -Wstringop-overflow is expected > > gcc/ChangeLog: > > PR middle-end/93646 > * tree-ssa-strlen.c (handle_builtin_stxncpy): Rename... > (handle_builtin_stxncpy_strncat): ...to this. Change first argument. > Issue only -Wstringop-overflow strncat, never -Wstringop-truncation. > (strlen_check_and_optimize_call): Adjust callee name. > > gcc/testsuite/ChangeLog: > > PR middle-end/93646 > * gcc.dg/Wstringop-overflow-31.c: New test. Not strictly a regression bugfix, but I think this is OK for the trunk, even in stage4.
jeff