Skip to content

[clang-repl] "Duplicate Definition of Symbol" for out of line definition for virtual function #141039

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Vipul-Cariappa opened this issue May 22, 2025 · 0 comments

Comments

@Vipul-Cariappa
Copy link
Contributor

clang-repl raises "Duplicate Definition of Symbol", when creating an object with an out-of-line virtual function.

clang-repl> struct Klass { virtual int get_value(); };
clang-repl> int Klass::get_value() { return 0; }
clang-repl> auto x1 = Klass();
error: Duplicate definition of symbol '_ZTV5Klass'
clang-repl> %quit

But if the virtual function in defined within the class, it does not raise the error:

clang-repl> struct Klass { virtual int get_value() { return 0; } };
clang-repl> auto x1 = Klass();
clang-repl> %quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants