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

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Testcase without division by zero:
int a[1] = { 0 };

void
foo ()
{
  a[({ 0; })] %= 5;
}

--- gcc/tree.c.jj       2018-02-22 12:37:02.634387690 +0100
+++ gcc/tree.c  2018-03-05 10:50:54.355557537 +0100
@@ -4352,6 +4352,11 @@ stabilize_reference_1 (tree e)
   switch (TREE_CODE_CLASS (code))
     {
     case tcc_exceptional:
+      /* Always wrap STATEMENT_LIST into SAVE_EXPR, even if it doesn't
+        have side-effects.  */
+      if (code == STATEMENT_LIST)
+       return save_expr (e);
+      /* FALLTHRU */
     case tcc_type:
     case tcc_declaration:
     case tcc_comparison:

fixes the ICE, but not really sure about it.  And wonder if
gimplify_statement_list or voidify_wrapper_expr shouldn't special-case
non-TREE_SIDE_EFFECTS STATEMENT_LISTs which contain just DEBUG_BEGIN_STMTs and
one other stmt to gimplify it more like how it woiuld be gimplified without -g.
E.g. I fear the retval.* will mismatch otherwise.

Reply via email to