re PR c++/19312 (ICE in stabilize_call when throwing a copy)
authorJason Merrill <jason@redhat.com>
Wed, 6 Apr 2005 04:57:39 +0000 (00:57 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 6 Apr 2005 04:57:39 +0000 (00:57 -0400)
        PR c++/19312
        * tree.c (stabilize_init): Don't bother trying to stabilize
        something with no side-effects.

From-SVN: r97691

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/g++.dg/eh/throw3.C [new file with mode: 0644]

index f37530d94cedcd01ca35bd514723b7259b95d781..aec76819098e86c3fa29502e1de982a971441cad 100644 (file)
@@ -1,3 +1,9 @@
+2005-04-06  Jason Merrill  <jason@redhat.com>
+
+       PR c++/19312
+       * tree.c (stabilize_init): Don't bother trying to stabilize
+       something with no side-effects.
+
 2005-04-05  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/20763
index 8b0d9aa872f766a5e1e2792bef2107af373b8325..5d80d5961628b0784896ce6fd05d20415ed3949e 100644 (file)
@@ -2257,7 +2257,10 @@ stabilize_init (tree init, tree *initp)
       if (TREE_CODE (t) == COND_EXPR)
        return false;
 
-      stabilize_call (t, initp);
+      /* The TARGET_EXPR might be initializing via bitwise copy from
+        another variable; leave that alone.  */
+      if (TREE_SIDE_EFFECTS (t))
+       stabilize_call (t, initp);
     }
 
   return true;
diff --git a/gcc/testsuite/g++.dg/eh/throw3.C b/gcc/testsuite/g++.dg/eh/throw3.C
new file mode 100644 (file)
index 0000000..3417eeb
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/19312
+
+struct A {};
+
+void foo(A a)
+{
+    throw (A)a;
+}