On 07/24/2018 02:16 PM, Martin Sebor wrote: > On 07/20/2018 04:20 AM, Richard Biener wrote: >> On Thu, 19 Jul 2018, Martin Sebor wrote: >> >>> Here's one more update with tweaks addressing a couple more >>> of Bernd's comments: >>> >>> 1) correct the use of TREE_STRING_LENGTH() where a number of >>> array elements is expected and not bytes >>> 2) set CHARTYPE as soon as it's first determined rather than >>> trying to extract it again later TREE_STRING_LENGTH is *really* poorly named. It practically invites misuse.
[ Snip ] > > > gcc-86532.diff > > > PR tree-optimization/86622 - incorrect strlen of array of array plus variable > offset > PR tree-optimization/86532 - Wrong code due to a wrong strlen folding > starting with r262522 > > gcc/ChangeLog: > > PR tree-optimization/86622 > PR tree-optimization/86532 > * builtins.h (string_length): Declare. > * builtins.c (c_strlen): Correct handling of non-constant offsets. > (check_access): Be prepared for non-constant length ranges. > (string_length): Make extern. > * expr.c (string_constant): Only handle the minor non-constant > array index. Use string_constant to compute the length of > a generic string constant. > > gcc/testsuite/ChangeLog: > > PR tree-optimization/86622 > PR tree-optimization/86532 > * gcc.c-torture/execute/strlen-2.c: New test. > * gcc.c-torture/execute/strlen-3.c: New test. > * gcc.c-torture/execute/strlen-4.c: New test. > OK jeff