Hi!

I've committed the following workaround for PR52582 to 4.7 branch (acked
on IRC by David and Richard) after bootstrapping/regtesting it on
powerpc64-linux (--with-cpu=default32 as well as -m64 defaulted build),
and for trunk committed just the testcase.  Richard committed some fix to
the trunk already, but we still should figure out why the DECL_EXTERNAL
on the devirtualized fndecl isn't set.

2012-03-14  Jakub Jelinek  <ja...@redhat.com>

        PR c++/52582
        * config/rs6000/rs6000.c (call_ABI_of_interest): Return true
        if c_node is NULL.

        * g++.dg/opt/pr52582.C: New test.

--- gcc/config/rs6000/rs6000.c.jj       2012-03-12 10:45:17.000000000 +0100
+++ gcc/config/rs6000/rs6000.c  2012-03-14 11:34:18.043648481 +0100
@@ -7452,6 +7452,9 @@ call_ABI_of_interest (tree fndecl)
       /* Interesting functions that we are emitting in this object file.  */
       c_node = cgraph_get_node (fndecl);
       c_node = cgraph_function_or_thunk_node (c_node, NULL);
+      if (c_node == NULL)
+       return true;
+
       return !cgraph_only_called_directly_p (c_node);
     }
   return false;
--- gcc/testsuite/g++.dg/opt/pr52582.C.jj       2012-03-14 11:29:34.008618924 
+0100
+++ gcc/testsuite/g++.dg/opt/pr52582.C  2012-03-14 11:20:26.000000000 +0100
@@ -0,0 +1,28 @@
+// PR c++/52582
+// { dg-do compile }
+// { dg-options "-O2" }
+
+inline void *operator new (__SIZE_TYPE__, void *p) throw ()
+{
+  return p;
+}
+
+struct B
+{
+  virtual ~B ();
+  B ();
+};
+
+struct A : B
+{
+  A () : B () {}
+  virtual void bar ();
+};
+
+void
+foo ()
+{
+  char a[64];
+  B *b = new (&a) A ();
+  b->~B ();
+}

        Jakub

Reply via email to