<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/102933>102933</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang][Modules] Assertion failure with out-of-line definition of virtual function in global module fragment of two modules
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
davidstone
</td>
</tr>
</table>
<pre>
The following valid translation units
```c++
module;
struct base {
virtual void f() const;
};
inline void base::f() const {
}
export module a;
```
```c++
module;
struct base {
virtual void f() const;
};
inline void base::f() const {
}
export module b;
import a;
```
Cause clang to crash with
```console
/opt/compiler-explorer/clang-assertions-trunk/bin/clang++ --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++23 -MD -MT CMakeFiles/bug.dir/b.cpp.o -MF CMakeFiles/bug.dir/b.cpp.o.d @CMakeFiles/bug.dir/b.cpp.o.modmap -o CMakeFiles/bug.dir/b.cpp.o -c /app/b.cpp
clang-20: /root/llvm-project/clang/lib/AST/VTableBuilder.cpp:186: {anonymous}::FinalOverriders::FinalOverriders(const clang::CXXRecordDecl*, clang::CharUnits, const clang::CXXRecordDecl*): Assertion `SubobjectOffsets.count(std::make_pair(MD->getParent(), SubobjectNumber)) && "Did not find subobject offset!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk-20240812/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free -clear-ast-before-backend -main-file-name b.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/app/build -fcoverage-compilation-dir=/app/build -resource-dir /opt/compiler-explorer/clang-assertions-trunk-20240812/lib/clang/20 -std=c++23 -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fmodule-file=a=CMakeFiles/bug.dir/a.pcm -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o CMakeFiles/bug.dir/b.cpp.o -x pcm CMakeFiles/bug.dir/b.pcm
1. <eof> parser at end of file
#0 0x0000000003abec78 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk-20240812/bin/clang-20+0x3abec78)
#1 0x0000000003abc3ec SignalHandler(int) Signals.cpp:0:0
#2 0x000075a426e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x000075a426e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#4 0x000075a426e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#5 0x000075a426e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#6 0x000075a426e2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#7 0x000075a426e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#8 0x0000000007c5b9bf (anonymous namespace)::FinalOverriders::FinalOverriders(clang::CXXRecordDecl const*, clang::CharUnits, clang::CXXRecordDecl const*) VTableBuilder.cpp:0:0
#9 0x0000000007c6b832 clang::ItaniumVTableContext::computeVTableRelatedInformation(clang::CXXRecordDecl const*) (/opt/compiler-explorer/clang-assertions-trunk-20240812/bin/clang-20+0x7c6b832)
#10 0x0000000003f803e6 clang::ItaniumVTableContext::getVTableLayout(clang::CXXRecordDecl const*) (/opt/compiler-explorer/clang-assertions-trunk-20240812/bin/clang-20+0x3f803e6)
#11 0x0000000003f83769 (anonymous namespace)::ItaniumCXXABI::getAddrOfVTable(clang::CXXRecordDecl const*, clang::CharUnits) ItaniumCXXABI.cpp:0:0
#12 0x0000000003f84ca4 (anonymous namespace)::ItaniumCXXABI::emitVTableDefinitions(clang::CodeGen::CodeGenVTables&, clang::CXXRecordDecl const*) ItaniumCXXABI.cpp:0:0
#13 0x00000000047e8441 clang::ASTReader::PassInterestingDeclsToConsumer() (/opt/compiler-explorer/clang-assertions-trunk-20240812/bin/clang-20+0x47e8441)
#14 0x000000000474861e non-virtual thunk to clang::ASTReader::StartTranslationUnit(clang::ASTConsumer*) (/opt/compiler-explorer/clang-assertions-trunk-20240812/bin/clang-20+0x474861e)
#15 0x00000000064d14f5 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240812/bin/clang-20+0x64d14f5)
#16 0x00000000043d17a8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk-20240812/bin/clang-20+0x43d17a8)
#17 0x000000000465d6d9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk-20240812/bin/clang-20+0x465d6d9)
#18 0x00000000045e1cde clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk-20240812/bin/clang-20+0x45e1cde)
#19 0x0000000004746a4e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk-20240812/bin/clang-20+0x4746a4e)
#20 0x0000000000c8fe2f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk-20240812/bin/clang-20+0xc8fe2f)
#21 0x0000000000c88fba ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#22 0x0000000000c8c8ee clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk-20240812/bin/clang-20+0xc8c8ee)
#23 0x0000000000b612d4 main (/opt/compiler-explorer/clang-assertions-trunk-20240812/bin/clang-20+0xb612d4)
#24 0x000075a426e29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#25 0x000075a426e29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#26 0x0000000000c88a6e _start (/opt/compiler-explorer/clang-assertions-trunk-20240812/bin/clang-20+0xc88a6e)
clang++: error: unable to execute command: Aborted (core dumped)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
```
See it live: https://godbolt.org/z/GoPr45qWK
This also means that no more than one module in a project can include Boost.System headers.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcWUFz2zjS_TX0pQsqCqQo6uCDLEUzqW_8TSr2zuSmAoEmhTEIcAHQcfbXbwGkbFFxxvbMurZqU0oigUDjve7GawBkzslGI14mi6tksb1gvT8YeynYvRTOG40XlRHfLm8PCLVRynyVuoF7pqQAb5l2inlpNPRaepek2yRdj_8W6fDhCb0Kn9jaGtErTLKr067O2557qJhDSJbjIwCAe2l9zxTcGymgTmiZ0BVwo51_srDcnlmTWkmNw5hgMsnWSbaejH6aJQw_GYsPnbEeBpTAniwfyfyPMazOLbfx6QvEN6x3CFwx3YA3wC1zB_gq_eF57xjtjMKxle5M5xO646btpEJL8KFTxqINbcEiYc6hDTnliLe9vkvorpL6-HhwNRDScE68MYofmNRJtv1Ty6Gz06xzB-MBgNTcKGOJkKzRxnnJHZBaGxKpTJudF0m2HUNMMyDXWyDXt7C5Zne4kwpdANg3MyHDTNWMd93MALnevdBlJiDJ0xf6tEa0rANiXpyPQ0J3rOuObYO_B5fSNMnW4bk1JrhIqfuWdNb8gdw_OXanZJXQ3frmNqG7325ZpfCql0qgjfay9bwsop3lFdNGf2tN72JyhuzbSc3Ur_dorRRo3fONtBySc5gwdtl8-fIZubFii1wldJ3QzeTxgdl_RGkJ7S8PXgWA62MGQVKkN31lqkD017p26N2Mm177hJYxsMFKy-5w37HgzvJ6S5LsQ4P-E7MYuwWbdAOPZv6_b6uQU6uw1hJaJLSAhNKtFKCNh1pqAe7YGUycNKHzhNKELqFmUq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