Skip to content

[C++20] [Modules] Clang didn't generate the virtual table to the unit containing the key function  #70585

@ChuanqiXu9

Description

@ChuanqiXu9

Reproducer:

// layer1.cppm export module foo:layer1; struct Fruit { virtual ~Fruit() = default; virtual void eval() = 0; }; struct Banana : public Fruit { Banana() {} void eval() override; }; // layer2.cppm export module foo:layer2; import :layer1; export void layer2_fun() { Banana *b = new Banana(); b->eval(); } void Banana::eval() { } 

Compiler layer2.cppm with:

clang++ -std=c++20 layer1.cppm --precompile -o foo-layer1.pcm clang++ -std=c++20 layer2.cppm -fprebuilt-module-path=. -S -emit-llvm -o - 

Then we can't see anything about the definition of virtual table. This violates the itanium ABI 5.2.3:

The virtual table for a class is emitted in the same object containing the definition of its key function, i.e. the first non-pure virtual function that is not inline at the point of class definition.

Metadata

Metadata

Assignees

Labels

clang:modulesC++20 modules and Clang Header Modules

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions