llvm-project
llvm-project copied to clipboard
Using Concept name as a Templated Struct name signals segfault
Got a crash after making a typo. Accidentally made a struct Specialization but the struct name was a already a concept name.
I expect that it's not so big a deal because it's invalid code...but it also probably shouldn't be segfault'ing either.
replicated on clang 15: https://godbolt.org/z/x6GMrar7f
Minimum reproducible example:
// cat test.cc
template<class T>
concept C1 = true;
template<typename A>
struct C1<A> {}
$ clang -std=c++20 test.cc
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: /usr/bin/clang-14 -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.cc -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 -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -fcoverage-compilation-dir=/home/johna/Documents/new-thing -resource-dir /usr/lib/clang/14.0.6 -internal-isystem /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0 -internal-isystem /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/x86_64-pc-linux-gnu -internal-isystem /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/backward -internal-isystem /usr/lib/clang/14.0.6/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../x86_64-pc-linux-gnu/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++20 -fdeprecated-macro -fdebug-compilation-dir=/home/johna/Documents/new-thing -ferror-limit 19 -stack-protector 2 -fgnuc-version=4.2.1 -fno-implicit-modules -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/test-22571b.o -x c++ test.cc
1. test.cc:5:14: current parser token '{'
#0 0x00007fd3004dd45a (/usr/lib/libLLVM-14.so+0xcd545a)
#1 0x00007fd3004daaef llvm::sys::RunSignalHandlers() (/usr/lib/libLLVM-14.so+0xcd2aef)
#2 0x00007fd3004dac3d (/usr/lib/libLLVM-14.so+0xcd2c3d)
#3 0x00007fd2ff422a00 (/usr/lib/libc.so.6+0x38a00)
#4 0x00007fd306faf7b0 clang::Diagnostic::FormatDiagnostic(char const*, char const*, llvm::SmallVectorImpl<char>&) const (/usr/lib/libclang-cpp.so.14+0x6eb7b0)
#5 0x00007fd306fb089f clang::Diagnostic::FormatDiagnostic(char const*, char const*, llvm::SmallVectorImpl<char>&) const (/usr/lib/libclang-cpp.so.14+0x6ec89f)
#6 0x00007fd306fb089f clang::Diagnostic::FormatDiagnostic(char const*, char const*, llvm::SmallVectorImpl<char>&) const (/usr/lib/libclang-cpp.so.14+0x6ec89f)
#7 0x00007fd306fb089f clang::Diagnostic::FormatDiagnostic(char const*, char const*, llvm::SmallVectorImpl<char>&) const (/usr/lib/libclang-cpp.so.14+0x6ec89f)
#8 0x00007fd306fb089f clang::Diagnostic::FormatDiagnostic(char const*, char const*, llvm::SmallVectorImpl<char>&) const (/usr/lib/libclang-cpp.so.14+0x6ec89f)
#9 0x00007fd306fb089f clang::Diagnostic::FormatDiagnostic(char const*, char const*, llvm::SmallVectorImpl<char>&) const (/usr/lib/libclang-cpp.so.14+0x6ec89f)
#10 0x00007fd306fb089f clang::Diagnostic::FormatDiagnostic(char const*, char const*, llvm::SmallVectorImpl<char>&) const (/usr/lib/libclang-cpp.so.14+0x6ec89f)
#11 0x00007fd3086a7602 clang::TextDiagnosticPrinter::HandleDiagnostic(clang::DiagnosticsEngine::Level, clang::Diagnostic const&) (/usr/lib/libclang-cpp.so.14+0x1de3602)
#12 0x00007fd306fa24b4 clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&) const (/usr/lib/libclang-cpp.so.14+0x6de4b4)
#13 0x00007fd306fa2778 clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool) (/usr/lib/libclang-cpp.so.14+0x6de778)
#14 0x00007fd306fa281e (/usr/lib/libclang-cpp.so.14+0x6de81e)
#15 0x00007fd3070dfe8e clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributesWithRange&) (/usr/lib/libclang-cpp.so.14+0x81be8e)
#16 0x00007fd3070c3657 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*) (/usr/lib/libclang-cpp.so.14+0x7ff657)
#17 0x00007fd30714fe29 clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/usr/lib/libclang-cpp.so.14+0x88be29)
#18 0x00007fd307150c9f clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/usr/lib/libclang-cpp.so.14+0x88cc9f)
#19 0x00007fd3071511e6 clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/usr/lib/libclang-cpp.so.14+0x88d1e6)
#20 0x00007fd3070d7dbc clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributesWithRange&, clang::SourceLocation*) (/usr/lib/libclang-cpp.so.14+0x813dbc)
#21 0x00007fd30715320c clang::Parser::ParseExternalDeclaration(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (/usr/lib/libclang-cpp.so.14+0x88f20c)
#22 0x00007fd3071539f6 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool) (/usr/lib/libclang-cpp.so.14+0x88f9f6)
#23 0x00007fd30709df18 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/libclang-cpp.so.14+0x7d9f18)
#24 0x00007fd308677919 clang::FrontendAction::Execute() (/usr/lib/libclang-cpp.so.14+0x1db3919)
#25 0x00007fd308616e07 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/libclang-cpp.so.14+0x1d52e07)
#26 0x00007fd3086ce7ca clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/libclang-cpp.so.14+0x1e0a7ca)
#27 0x000055838cd0d6f1 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/bin/clang-14+0x176f1)
#28 0x000055838cd0f337 (/usr/bin/clang-14+0x19337)
#29 0x000055838cd03216 main (/usr/bin/clang-14+0xd216)
#30 0x00007fd2ff40d290 (/usr/lib/libc.so.6+0x23290)
#31 0x00007fd2ff40d34a __libc_start_main (/usr/lib/libc.so.6+0x2334a)
#32 0x000055838cd05655 _start (/usr/bin/clang-14+0xf655)
clang-14: error: unable to execute command: Segmentation fault (core dumped)
clang-14: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 14.0.6
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang-14: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-14: note: diagnostic msg: /tmp/test-a77837.cpp
clang-14: note: diagnostic msg: /tmp/test-a77837.sh
clang-14: note: diagnostic msg:
********************