[clang] [clang-repl] fix vtable symbol duplication error (closes #141039) (PR #185648)

Aaron Jomy via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 11 10:37:24 PDT 2026


aaronj0 wrote:

@vgvassilev asked me to ran this test with ROOT and Cling, and it seems to work:

Cling 1.3 (LLVM20):
```
(.venv_cling) ➜  ~ /home/sata-drive/cling-llvm-build/bin/cling

****************** CLING ******************
* Type C++ code and press enter to run it *
*     Type .? for help and .q to exit     *
*******************************************
[cling]$ extern "C" int printf(const char *, ...);
[cling]$ struct One { virtual void print() { printf("ONE\n"); } };
[cling]$ 
[cling]$ One().print();
ONE
[cling]$ struct Two { virtual void print(); };
[cling]$ void Two::print() { printf("TWO\n"); }
[cling]$ Two().print();
TWO
[cling]$ 
```
ROOT master:

```
root [0] .x test_virtualdef.cpp 
ONE
TWO
warning: Failed to call `test_virtualdef()` to execute the macro.
Add this function or rename the macro. Falling back to `.L`.
root [1] ^C
root [1] .q
(root_venv) ➜  ~ cat test_virtualdef.cpp 
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

(root_venv) ➜  ~ 
```

https://github.com/llvm/llvm-project/pull/185648


More information about the cfe-commits mailing list