https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89500
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Author: jakub Date: Tue Feb 26 20:36:29 2019 New Revision: 269230 URL: https://gcc.gnu.org/viewcvs?rev=269230&root=gcc&view=rev Log: PR tree-optimization/89500 * tree-ssa-strlen.c (stridx_strlenloc): Adjust comment. (handle_builtin_strlen): Remove noncst_bound variable. Always optimize strnlen (x, 0) to 0. Optimize strnlen (x, cst) to cst if the first cst bytes starting at x are known to be non-zero, even if the string is not zero terminated. Don't try to modify *si for strnlen. Update strlen_to_stridx only for strlen or if we can prove strnlen returns the same value as strlen would. * gcc.dg/pr89500.c: New test. * gcc.dg/Wstringop-overflow-10.c: New test. * gcc.dg/strlenopt-60.c: New test. Added: trunk/gcc/testsuite/gcc.dg/Wstringop-overflow-10.c trunk/gcc/testsuite/gcc.dg/pr89500.c trunk/gcc/testsuite/gcc.dg/strlenopt-60.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-strlen.c