[clang] [clang-repl] fix vtable symbol duplication error (closes #141039) (PR #185648)
Vipul Cariappa via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 12 01:31:00 PDT 2026
================
@@ -0,0 +1,19 @@
+// REQUIRES: host-supports-jit
+// RUN: cat %s | clang-repl | FileCheck %s
+// virtual functions defined outside of class had duplicate symbols:
+// duplicate definition of symbol '__ZTV3Two' (i.e., vtable for Two)
+// see https://github.com/llvm/llvm-project/issues/141039.
+// fixed in PR #185648
+
+extern "C" int printf(const char *, ...);
+
+struct One { virtual void print() { printf("ONE\n"); } };
+One().print();
+// CHECK: ONE
+
+struct Two { virtual void print(); };
+void Two::print() { printf("TWO\n"); }
+Two().print();
+// CHECK: TWO
----------------
Vipul-Cariappa wrote:
Can we have a test with more than 1 virtual function.
https://github.com/llvm/llvm-project/pull/185648
More information about the cfe-commits
mailing list