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

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Tried now also:
--- gcc/gimplify.c.jj   2020-04-19 12:10:35.700627184 +0200
+++ gcc/gimplify.c      2020-04-21 12:24:41.444307978 +0200
@@ -886,7 +886,11 @@ mostly_copy_tree_r (tree *tp, int *walk_

   /* Cope with the statement expression extension.  */
   else if (code == STATEMENT_LIST)
-    ;
+    {
+      if (!TREE_SIDE_EFFECTS (t))
+       if (tree nt = expr_single (t))
+         *tp = nt;
+    }

   /* Leave the bulk of the work to copy_tree_r itself.  */
   else
--- gcc/testsuite/g++.dg/other/pr94340.C.jj     2020-04-21 12:15:35.855765641
+0200
+++ gcc/testsuite/g++.dg/other/pr94340.C        2020-04-21 12:15:35.855765641
+0200
@@ -0,0 +1,16 @@
+// PR debug/94340
+// { dg-do compile }
+// { dg-options "-O -fcompare-debug" }
+
+struct D { int i; D (); ~D (); };
+D foo ();
+
+void
+bar (void)
+{
+  if (
+      ({
+         foo ();
+       }).i)
+    return;
+}
--- gcc/testsuite/g++.dg/other/pr93786.C.jj     2020-04-21 12:15:35.855765641
+0200
+++ gcc/testsuite/g++.dg/other/pr93786.C        2020-04-21 12:15:35.855765641
+0200
@@ -0,0 +1,11 @@
+// PR middle-end/93786
+// { dg-do compile }
+// { dg-options "-O2 -fcompare-debug" }
+
+struct S { virtual void bar (); };
+
+void
+foo (S *s)
+{
+  ({ s; })->bar ();
+}

and while it doesn't ICE, it fails -fcompare-debug on both tests.
So, I'm afraid I have no further ideas what to do here, everything I've tried
didn't work.
Alex, do you think you could have a look at this for GCC11?
Thanks.

Reply via email to