Hi,
the testcase expose a bug in nothrow propagation.  We forget to set the
flag that call from thunk may throw.   I probably should flip the default
of the flag to prevent similar bugs next stage1.

Bootstrapped/regtested x86_64-linux. Comitted.

Honza

        PR ipa/68184
        * g++.dg/torture/pr68184.C: New testcase.
        * cgraphunit.c (cgraph_node::analyze): Set can_throw_external.
Index: testsuite/g++.dg/torture/pr68184.C
===================================================================
--- testsuite/g++.dg/torture/pr68184.C  (revision 0)
+++ testsuite/g++.dg/torture/pr68184.C  (revision 0)
@@ -0,0 +1,31 @@
+// { dg-do run }
+namespace {
+struct IFoo { virtual void foo() = 0; };
+struct IBar { virtual void bar() = 0; };
+
+struct FooBar : private IBar, private IFoo
+{
+    void call_foo()
+    {
+        try
+        {
+            static_cast<IFoo*>(this)->foo();
+        }
+        catch( ... ) {}
+    }
+    void foo() { throw 1; }
+    void bar()  {}
+};
+
+void test()
+{
+    FooBar foobar;
+    foobar.call_foo();
+}
+}
+int main()
+{
+    test();
+    return 0;
+}
+
Index: cgraphunit.c
===================================================================
--- cgraphunit.c        (revision 231122)
+++ cgraphunit.c        (working copy)
@@ -575,6 +575,7 @@ cgraph_node::analyze (void)
       cgraph_node *t = cgraph_node::get (thunk.alias);
 
       create_edge (t, NULL, 0, CGRAPH_FREQ_BASE);
+      callees->can_throw_external = !TREE_NOTHROW (t->decl);
       /* Target code in expand_thunk may need the thunk's target
         to be analyzed, so recurse here.  */
       if (!t->analyzed)

Reply via email to