[Bug middle-end/59037] [4.8/4.9 Regression] ICE when accessing invalid element (nelts + 1) of vector

glisse at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Nov 10 08:34:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59037

--- Comment #5 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to vries from comment #4)
> Tentative patch:
> ...
> diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
> index 93b8970..6f2b4fb 100644
> --- a/gcc/tree-ssa-forwprop.c
> +++ b/gcc/tree-ssa-forwprop.c
> @@ -3046,6 +3046,8 @@ simplify_bitfield_ref (gimple_stmt_iterator *gsi)
>        if (TREE_CODE (m) != VECTOR_CST)
> 	return false;
>        nelts = VECTOR_CST_NELTS (m);

Add a comment here explaining why this isn't an assert?

> +      if (idx >= nelts)
> +       return false;
>        idx = TREE_INT_CST_LOW (VECTOR_CST_ELT (m, idx));
>        idx %= 2 * nelts;
>        if (idx < nelts)

I think it would be even better to fix whatever created that BIT_FIELD_REF, if
you are motivated (though your patch isn't wrong).


More information about the Gcc-bugs mailing list