Issue 204561
Summary [clang] Assertion `isa<CXXRecordDecl>(D->getDeclContext()) && "not a member specialization"' failed.
Labels clang:frontend, crash, generated by fuzzer
Assignees
Reporter k-arrows
    Reproducer:
https://godbolt.org/z/vb5zPof51
```cpp
template <typename T> struct A {
  void B { int y = 0; };
  template <typename U> int x = 0;
}

template <typename U>
struct A<long>::B<U &> {
};
template <typename U> int A<int>::x = 3;
template <> template <typename U> int A<int>::x<U &> = 4;

static_assert(A<long>::x<int &> == 5);
```

Backtrace:
```console
clang++: /root/llvm-project/llvm/tools/clang/lib/Sema/SemaLookup.cpp:1809: bool hasAcceptableMemberSpecialization(clang::Sema&, const clang::NamedDecl*, llvm::SmallVectorImpl<clang::Module*>*, clang::Sema::AcceptableKind): Assertion `isa<CXXRecordDecl>(D->getDeclContext()) && "not a member specialization"' 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 -std=c++20 <source>
1.	<source>:12:33: current parser token '=='
 #0 0x000000000434c4d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x434c4d8)
 #1 0x0000000004349414 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4349414)
 #2 0x0000000004349a34 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4349a34)
 #3 0x0000000004286f78 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #4 0x0000730464645330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 #5 0x000073046469eb2c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c)
 #6 0x000073046464527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
 #7 0x00007304646288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
 #8 0x000073046462881b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
 #9 0x000073046463b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#10 0x000000000734e4e4 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x734e4e4)
#11 0x000000000764a054 (anonymous namespace)::ExplicitSpecializationVisibilityChecker::check(clang::NamedDecl*) (.constprop.0) SemaTemplate.cpp:0:0
#12 0x000000000764a33b clang::Sema::checkSpecializationReachability(clang::SourceLocation, clang::NamedDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x764a33b)
#13 0x000000000767249a clang::Sema::CheckVarTemplateId(clang::VarTemplateDecl*, clang::SourceLocation, clang::SourceLocation, clang::TemplateArgumentListInfo const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x767249a)
#14 0x0000000007672e44 clang::Sema::CheckVarTemplateId(clang::CXXScopeSpec const&, clang::DeclarationNameInfo const&, clang::VarTemplateDecl*, clang::NamedDecl*, clang::SourceLocation, clang::TemplateArgumentListInfo const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7672e44)
#15 0x00000000076730a7 clang::Sema::BuildTemplateIdExpr(clang::CXXScopeSpec const&, clang::SourceLocation, clang::LookupResult&, bool, clang::TemplateArgumentListInfo const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x76730a7)
#16 0x00000000071a0878 clang::Sema::ActOnIdExpression(clang::Scope*, clang::CXXScopeSpec&, clang::SourceLocation, clang::UnqualifiedId&, bool, bool, clang::CorrectionCandidateCallback*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x71a0878)
#17 0x0000000006cd3501 clang::Parser::tryParseCXXIdExpression(clang::CXXScopeSpec&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6cd3501)
#18 0x0000000006cd379e clang::Parser::ParseCXXIdExpression(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6cd379e)
#19 0x0000000006cb7934 clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6cb7934)
#20 0x0000000006cb7210 clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6cb7210)
#21 0x0000000006cc410e clang::Parser::ParseConstantExpressionInExprEvalContext(clang::TypoCorrectionTypeBehavior) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6cc410e)
#22 0x0000000006c9b8a6 clang::Parser::ParseStaticAssertDeclaration(clang::SourceLocation&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c9b8a6)
#23 0x0000000006c8a146 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c8a146)
#24 0x0000000006c45ce6 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c45ce6)
#25 0x0000000006c46bd5 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c46bd5)
#26 0x0000000006c27aba clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c27aba)
#27 0x0000000004e44b58 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e44b58)
#28 0x000000000517d638 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x517d638)
#29 0x00000000050f936d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x50f936d)
#30 0x000000000527c1bd clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x527c1bd)
#31 0x0000000000dcc82c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdcc82c)
#32 0x0000000000dc350a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#33 0x0000000000dc368d 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
#34 0x0000000004eb7b59 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
#35 0x00000000042873b4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42873b4)
#36 0x0000000004eb81a6 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
#37 0x0000000004e74b42 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e74b42)
#38 0x0000000004e75aee 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+++0x4e75aee)
#39 0x0000000004e7d325 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e7d325)
#40 0x0000000000dc8da2 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdc8da2)
#41 0x0000000000cc8a4a main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcc8a4a)
#42 0x000073046462a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#43 0x000073046462a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#44 0x0000000000dc2eb5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdc2eb5)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Compiler returned: 134
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to