This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for pure virtual/templates
- To: egcs-patches at egcs dot cygnus dot com
- Subject: C++ PATCH for pure virtual/templates
- From: mark at codesourcery dot com
- Date: Mon, 24 May 1999 23:43:48 -0700
- Organization: CodeSourcery, LLC
This patch fixes a crash when a pure virtual function was instantiated
after its the vtable for its class was layed out.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
1999-05-24 Mark Mitchell <mark@codesourcery.com>
* decl2.c (mark_vtable_entries): Don't make a copy of a function,
and then make it look like `abort'. Just use `abort' instead.
Index: testsuite/g++.old-deja/g++.pt/virtual2.C
===================================================================
RCS file: virtual2.C
diff -N virtual2.C
--- /dev/null Sat Dec 5 20:30:03 1998
+++ virtual2.C Mon May 24 23:25:49 1999
@@ -0,0 +1,21 @@
+// Build don't link:
+// Origin: Mark Mitchell <mark@codesourcery.com>
+
+template <class T>
+struct B
+{
+ virtual void f() = 0;
+};
+
+template <class T>
+struct D : public B<T> {
+ virtual void f();
+};
+
+void g() {
+ B<int>* bi = new D<int>;
+};
+
+template <class T>
+void B<T>::f() {}
+
Index: cp/decl2.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl2.c,v
retrieving revision 1.219
diff -u -p -r1.219 decl2.c
--- decl2.c 1999/05/24 00:46:50 1.219
+++ decl2.c 1999/05/25 06:25:52
@@ -2424,8 +2424,7 @@ mark_vtable_entries (decl)
TREE_ADDRESSABLE (fn) = 1;
if (DECL_LANG_SPECIFIC (fn) && DECL_ABSTRACT_VIRTUAL_P (fn))
{
- TREE_OPERAND (fnaddr, 0) = fn = copy_node (fn);
- DECL_RTL (fn) = DECL_RTL (abort_fndecl);
+ TREE_OPERAND (fnaddr, 0) = abort_fndecl;
mark_used (abort_fndecl);
}
if (TREE_CODE (fn) == THUNK_DECL && DECL_EXTERNAL (fn))