re PR c++/47873 (virtual Inheritance - Covariant Virtual Function - Segfault)
authorJason Merrill <jason@redhat.com>
Mon, 28 Feb 2011 21:41:21 +0000 (16:41 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 28 Feb 2011 21:41:21 +0000 (16:41 -0500)
PR c++/47873
* class.c (update_vtable_entry_for_fn): Check BINFO_LOST_PRIMARY_P
after checking for a non-thunk.

From-SVN: r170576

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/inherit/covariant18.C [new file with mode: 0644]

index 50e4b48d5ea36262a9af8840014651ebbf3c8c5c..d1b1b4aaf4ed4c69dcdd6029d00da9f4f2c060a4 100644 (file)
@@ -1,3 +1,9 @@
+2011-02-28  Jason Merrill  <jason@redhat.com>
+
+       PR c++/47873
+       * class.c (update_vtable_entry_for_fn): Check BINFO_LOST_PRIMARY_P
+       after checking for a non-thunk.
+
 2011-02-26  Jason Merrill  <jason@redhat.com>
 
        PR c++/47904
index 0d485fc6ac7ec13af339bd6281324681369af76e..1325260f51e2a0a34b316154fa1c381cd66da68d 100644 (file)
@@ -2250,10 +2250,10 @@ update_vtable_entry_for_fn (tree t, tree binfo, tree fn, tree* virtuals,
        {
          tree main_binfo = TYPE_BINFO (BINFO_TYPE (b));
          tree bv = chain_index (ix, BINFO_VIRTUALS (main_binfo));
-         if (BINFO_LOST_PRIMARY_P (b))
-           lost = true;
          if (!DECL_THUNK_P (TREE_VALUE (bv)))
            break;
+         if (BINFO_LOST_PRIMARY_P (b))
+           lost = true;
        }
       first_defn = b;
     }
index 10c430a3c886c520eda4b5534c1af064dcf61fd5..fc2ad4fd02c468a98a129dcd92a249bee99c8107 100644 (file)
@@ -1,3 +1,7 @@
+2011-02-28  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/inherit/covariant18.C: New.
+
 2011-02-28  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/47893
diff --git a/gcc/testsuite/g++.dg/inherit/covariant18.C b/gcc/testsuite/g++.dg/inherit/covariant18.C
new file mode 100644 (file)
index 0000000..31e6216
--- /dev/null
@@ -0,0 +1,41 @@
+// PR c++/47873
+// { dg-do run }
+
+struct Base
+{
+    virtual ~Base(){}
+
+    virtual Base& This() { return *this; }
+};
+
+
+struct Ent : virtual Base
+{
+    void *m_Body;
+
+    Ent& This() { return *this; }
+
+    virtual Ent& body()
+    {
+        return This();
+    }
+
+};
+
+
+struct Msg : virtual Ent
+{
+    Msg()
+    {
+        body();
+    }
+
+    Msg& This() { return *this; }
+};
+
+int main()
+{
+    Msg m;
+
+    return 0;
+}