https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90866

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Martin Liška from comment #3)
> So my patch survives bootstrap and regression tests, can you please Martin
> take the issue?
> 
> Patch candidate:
> diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c
> index 944650cecd5..a9b1147a2e7 100644
> --- a/gcc/tree-ssa-strlen.c
> +++ b/gcc/tree-ssa-strlen.c
> @@ -324,7 +324,7 @@ get_stridx (tree exp)
>                     off = TREE_OPERAND (ptr, 1);
>                     /* Scale the array index by the size of the element
>                        type (normally 1 for char).  */
> -                   off = fold_build2 (MULT_EXPR, TREE_TYPE (off), off,
> +                   off = fold_build2 (MULT_EXPR, TREE_TYPE (eltsize), off,
>                                        eltsize);
>                     ptr = TREE_OPERAND (ptr, 0);
>                   }

Of course this shouldn't make a difference.  The issue is likely a
type mismatch and 'off' being a pointer type?  Probably
mem_ref_offset () should be used to extract it.

Reply via email to