This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/79536] [5/6/7 Regression] ICE in fold_binary_loc, at fold-const.c:9060
- From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 16 Feb 2017 10:02:36 +0000
- Subject: [Bug middle-end/79536] [5/6/7 Regression] ICE in fold_binary_loc, at fold-const.c:9060
- Auto-submitted: auto-generated
- References: <bug-79536-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79536
--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
The problem here is that we have a NOP_EXPR: (int) -x. negate_expr_p returns
true for that, which means that fold_negate_expr cannot return NULL_TREE. But
that's what happens, and that leads to a crash in fold_build2:
581 case COMPLEX_EXPR:
582 if (negate_expr_p (t))
583 return fold_build2_loc (loc, COMPLEX_EXPR, type,
584 fold_negate_expr (loc, TREE_OPERAND (t, 0)),
585 fold_negate_expr (loc, TREE_OPERAND (t, 1)));
I see that negate_expr_p has STRIP_SIGN_NOPS, so the "(int) -x" becomes "-x",
but fold_negate_expr doesn't have any STRIP_SIGN_NOPS.