https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88771
--- Comment #19 from Martin Sebor <msebor at gcc dot gnu.org> --- Author: msebor Date: Mon Feb 11 17:44:05 2019 New Revision: 268775 URL: https://gcc.gnu.org/viewcvs?rev=268775&root=gcc&view=rev Log: PR tree-optimization/88771 - Misleading -Werror=array-bounds error gcc/ChangeLog: PR tree-optimization/88771 * gimple-ssa-warn-restrict.c (pass_wrestrict::gate): Also enable when -Wstringop-overflow is set. (builtin_memref::builtin_memref): Adjust excessive upper bound only when lower bound is not excessive. (maybe_diag_overlap): Detect and diagnose excessive bounds via -Wstringop-ovefflow. (maybe_diag_offset_bounds): Rename... (maybe_diag_access_bounds): ...to this. (check_bounds_or_overlap): Adjust for name change above. gcc/testsuite/ChangeLog: PR tree-optimization/88771 * gcc.dg/Wstringop-overflow-8.c: New test. * gcc.dg/Wstringop-overflow-9.c: New test. * gcc.dg/Warray-bounds-40.c: New test. * gcc.dg/builtin-stpncpy.c: Adjust. * gcc.dg/builtin-stringop-chk-4.c: Adjust. * g++.dg/opt/memcpy1.C: Adjust. Added: trunk/gcc/testsuite/gcc.dg/Warray-bounds-40.c trunk/gcc/testsuite/gcc.dg/Wstringop-overflow-8.c trunk/gcc/testsuite/gcc.dg/Wstringop-overflow-9.c Modified: trunk/gcc/ChangeLog trunk/gcc/gimple-ssa-warn-restrict.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/opt/memcpy1.C trunk/gcc/testsuite/gcc.dg/builtin-stpncpy.c trunk/gcc/testsuite/gcc.dg/builtin-stringop-chk-4.c