[Bug c++/56961] stack overflow in gimplifier with volatile field
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jun 5 12:35:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56961
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #7)
> I suggest
>
> Index: gcc/cp/cp-gimplify.c
> ===================================================================
> --- gcc/cp/cp-gimplify.c (revision 211262)
> +++ gcc/cp/cp-gimplify.c (working copy)
> @@ -630,18 +630,8 @@ cp_gimplify_expr (tree *expr_p, gimple_s
> Also drop volatile variables on the RHS to avoid infinite
> recursion from gimplify_expr trying to load the value. */
> if (!TREE_SIDE_EFFECTS (op1)
> - || (DECL_P (op1) && TREE_THIS_VOLATILE (op1)))
> + || TREE_THIS_VOLATILE (op1))
> *expr_p = op0;
> - else if (TREE_CODE (op1) == MEM_REF
> - && TREE_THIS_VOLATILE (op1))
> - {
> - /* Similarly for volatile MEM_REFs on the RHS. */
> - if (!TREE_SIDE_EFFECTS (TREE_OPERAND (op1, 0)))
> - *expr_p = op0;
> - else
> - *expr_p = build2 (COMPOUND_EXPR, TREE_TYPE (*expr_p),
> - TREE_OPERAND (op1, 0), op0);
> - }
> else
> *expr_p = build2 (COMPOUND_EXPR, TREE_TYPE (*expr_p),
> op0, op1);
This might of course drop arbitrary side-effects of op1 such as
a volatile load from a.b[foo()] where foo () would be dropped.
So it isn't really correct.
More information about the Gcc-bugs
mailing list