Issue 241854
Summary [clang] Assertion `TSK != TSK_ExplicitInstantiationDefinition && TSK != TSK_ImplicitInstantiation && "Instantiations don't have key functions"' failed.
Labels clang:frontend, crash, generated by fuzzer
Assignees
Reporter k-arrows
    Reproducer:
https://godbolt.org/z/x83To14G7
```cpp
template <class T> struct A {};
template <class T> struct B : A<T> {
  template <class T> struct S;
  template <> struct S<int> {
    virtual void foo();
 };
  void bar() { S<int> s; }
};

template struct B<int>;
```

Backtrace:
```console
clang++: /root/llvm-project/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp:20106: bool clang::Sema::DefineUsedVTables(): Assertion `TSK != TSK_ExplicitInstantiationDefinition && TSK != TSK_ImplicitInstantiation && "Instantiations don't have key functions"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and dumped files.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics <source>
1.	<eof> parser at end of file
 #0 0x0000000004f471a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f471a8)
 #1 0x0000000004f44404 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f44404)
 #2 0x0000000004f44a3c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f44a3c)
 #3 0x0000000004e7e6b8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #4 0x00007bd5ece45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 #5 0x00007bd5ece9ec0c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9ec0c)
 #6 0x00007bd5ece4527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
 #7 0x00007bd5ece288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
 #8 0x00007bd5ece2881b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
 #9 0x00007bd5ece3b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#10 0x0000000009502674 clang::Sema::DefineUsedVTables() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x9502674)
#11 0x00000000091bfcdf clang::Sema::ActOnEndOfTranslationUnitFragment(clang::TUFragmentKind) (.part.0) Sema.cpp:0:0
#12 0x00000000091c0122 clang::Sema::ActOnEndOfTranslationUnit() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x91c0122)
#13 0x000000000901844a clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x901844a)
#14 0x0000000008ff41ea clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8ff41ea)
#15 0x0000000005a47468 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5a47468)
#16 0x0000000005d70e08 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5d70e08)
#17 0x0000000005cfda1d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5cfda1d)
#18 0x0000000005e47683 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5e47683)
#19 0x0000000001713ea8 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1713ea8)
#20 0x000000000170adaa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#21 0x000000000170af33 int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#22 0x0000000005ac0c49 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#23 0x0000000004e7eab4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e7eab4)
#24 0x0000000005ac17b5 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#25 0x0000000005a7e5d2 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5a7e5d2)
#26 0x0000000005a8188c clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5a8188c)
#27 0x0000000005a8dd85 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5a8dd85)
#28 0x00000000017104fa clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x17104fa)
#29 0x0000000001696a43 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1696a43)
#30 0x00007bd5ece2a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#31 0x00007bd5ece2a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#32 0x000000000170a755 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x170a755)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Program terminated with signal SIGABRT (6)
Compiler returned: 134
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to