Virtual cloned functions have distinct vtable indices, stream them
explicitly.
As such, this patch ensures that DECL_VINDEX is properly passed on for
cloned functions as well to prevent this from causing issues.
PR c++/103499
gcc/cp/ChangeLog:
* module.cc (trees_out::decl_node): Write DECL_VINDEX for
virtual clones.
(trees_in::tree_node): Read DECL_VINDEX for virtual clones.
gcc/testsuite/ChangeLog:
* g++.dg/modules/pr103499_a.C: New test.
* g++.dg/modules/pr103499_b.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Signed-off-by: Nathan Sidwell <nathan@acm.org>
tree_node (target);
tree_node (DECL_NAME (decl));
+ if (DECL_VIRTUAL_P (decl))
+ tree_node (DECL_VINDEX (decl));
int tag = insert (decl);
if (streaming_p ())
dump (dumper::TREE)
}
}
+ /* A clone might have a different vtable entry. */
+ if (res && DECL_VIRTUAL_P (res))
+ DECL_VINDEX (res) = tree_node ();
+
if (!res)
set_overrun ();
int tag = insert (res);
--- /dev/null
+// PR c++/103499
+// { dg-module-do compile }
+// { dg-additional-options "-fmodules-ts" }
+// { dg-module-cmi pr103499 }
+
+export module pr103499;
+
+export struct base {
+ virtual ~base() = default;
+};
+
+export struct derived : base {};
--- /dev/null
+// PR c++/103499
+// { dg-additional-options "-fmodules-ts" }
+
+import pr103499;
+
+void test(derived* p) {
+ delete p;
+}