On 05/14/2018 04:41 PM, Martin Sebor wrote: > r256683 committed to GCC 8 to avoiding duplicate instances of > -Wstringop-overflow warnings on some targets has the unintended > side-effect of suppressing even singleton instances of the warning > in cases such as 'strcat (strcpy (buf, "hello "), "world!")' when > _FORTIFY_SOURCE is defined. > > The attached patch restores the warning for the trunk. > > Since this is a regression in a security feature and the warning > isn't prone to false positives (I don't think I've seen any when > _FORTIFY_SOURCE is defined), I'd also like the fix considered for > the 8 branch. > > Thanks > Martin > > gcc-85259.diff > > > PR tree-optimization/85259 - Missing -Wstringop-overflow= since r256683 > > gcc/ChangeLog: > > PR tree-optimization/85259 > * builtins.c (compute_objsize): Handle constant offsets. > * gimple-ssa-warn-restrict.c (maybe_diag_offset_bounds): Return > true iff a warning has been issued. > * gimple.h (gimple_nonartificial_location): New function. > * tree-ssa-strlen.c (maybe_diag_stxncpy_trunc): Call > gimple_nonartificial_location and handle -Wno-system-headers. > (handle_builtin_stxncpy): Same. > > gcc/testsuite/ChangeLog: > > PR tree-optimization/85259 > * gcc.dg/Wstringop-overflow-5.c: New test. > * gcc.dg/Wstringop-overflow-6.c: New test. OK for the trunk.
The general guidance we've received is to not try and fix these on the release branches. However, I think this one deserves an exception to the general guidance. So OK for the gcc-8 branch. jeff