Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang-20 Crash: TemplateArgument kind is not expected for NTTP UNREACHABLE executed at /root/llvm-project/clang/lib/AST/ASTDiagnostic.cpp:1245! #114758

Open
iamanonymouscs opened this issue Nov 4, 2024 · 4 comments
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid] regression

Comments

@iamanonymouscs
Copy link

Description

I encountered a crash in Clang-20 when compiling the following code snippet:

template<int N> struct A
{
    void foo() throw(int[N]);
};

A<0> a;

template<typename T> struct A
{
    void foo() throw(typename T::X);
};

A<void> a;

The compilation command used was:

clang++ -O3 -ffast-math -fno-ident -std=c++23 -fno-rtlib-add-rpath -Wall -Wextra -fno-strict-aliasing -fwrapv -g -fsanitize=address  test.cpp 

Following the error messages, the compiler crashed with an assertion failure:

TemplateArgument kind is not expected for NTTP UNREACHABLE executed at /root/llvm-project/clang/lib/AST/ASTDiagnostic.cpp:1245!

Error Message

<source>:3:16: error: ISO C++17 does not allow dynamic exception specifications [-Wdynamic-exception-spec]
    3 |     void foo() throw(int[N]);
      |                ^~~~~~~~~~~~~
<source>:3:16: note: use 'noexcept(false)' instead
    3 |     void foo() throw(int[N]);
      |                ^~~~~~~~~~~~~
      |                noexcept(false)
<source>:8:19: error: template parameter has a different kind in template redeclaration
    8 | template<typename T> struct A
      |                   ^
<source>:1:14: note: previous template declaration is here
    1 | template<int N> struct A
      |              ^
TemplateArgument kind is not expected for NTTP
UNREACHABLE executed at /root/llvm-project/clang/lib/AST/ASTDiagnostic.cpp:1245!
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/bin/clang++ -gdwarf-4 -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 -O3 -ffast-math -fno-ident -std=c++23 -fno-rtlib-add-rpath -Wall -Wextra -fno-strict-aliasing -fwrapv -g -fsanitize=address <source>
1.	<source>:13:10: current parser token ';'
 #0 0x0000000003be87b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3be87b8)
 #1 0x0000000003be64bc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3be64bc)
 #2 0x0000000003b33df8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007b7ccba42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007b7ccba969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007b7ccba42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007b7ccba287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x0000000003b3f71a (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b3f71a)
 #8 0x000000000793b6ce (anonymous namespace)::TemplateDiff::InitializeNonTypeDiffVariables(clang::ASTContext&, (anonymous namespace)::TemplateDiff::TSTiterator const&, clang::NonTypeTemplateParmDecl*, llvm::APSInt&, bool&, clang::QualType&, bool&, clang::Expr*&, clang::ValueDecl*&, bool&) (.isra.0) ASTDiagnostic.cpp:0:0
 #9 0x000000000793bd4e (anonymous namespace)::TemplateDiff::DiffTemplate(clang::TemplateSpecializationType const*, clang::TemplateSpecializationType const*) ASTDiagnostic.cpp:0:0
#10 0x0000000007942cec FormatTemplateTypeDiff(clang::ASTContext&, clang::QualType, clang::QualType, bool, bool, bool, bool, llvm::raw_ostream&) ASTDiagnostic.cpp:0:0
#11 0x000000000794343c clang::FormatASTNodeDiagnosticArgument(clang::DiagnosticsEngine::ArgumentKind, long, llvm::StringRef, llvm::StringRef, llvm::ArrayRef<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>>, llvm::SmallVectorImpl<char>&, void*, llvm::ArrayRef<long>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x794343c)
#12 0x0000000003e12915 clang::Diagnostic::FormatDiagnostic(char const*, char const*, llvm::SmallVectorImpl<char>&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e12915)
#13 0x000000000487557a clang::TextDiagnosticPrinter::HandleDiagnostic(clang::DiagnosticsEngine::Level, clang::Diagnostic const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x487557a)
#14 0x0000000003e1e1fb clang::DiagnosticIDs::EmitDiag(clang::DiagnosticsEngine&, clang::DiagnosticBuilder const&, clang::DiagnosticIDs::Level) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e1e1fb)
#15 0x0000000003e1e7f3 clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&, clang::DiagnosticBuilder const&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e1e7f3)
#16 0x0000000003e11edf clang::DiagnosticsEngine::EmitDiagnostic(clang::DiagnosticBuilder const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e11edf)
#17 0x0000000006869cc4 clang::Sema::EmitDiagnostic(unsigned int, clang::DiagnosticBuilder const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6869cc4)
#18 0x00000000068e1a88 clang::SemaBase::ImmediateDiagBuilder::~ImmediateDiagBuilder() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x68e1a88)
#19 0x0000000006858a73 clang::SemaBase::SemaDiagnosticBuilder::~SemaDiagnosticBuilder() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6858a73)
#20 0x0000000006a80a43 diagnoseVarDeclTypeMismatch(clang::Sema&, clang::VarDecl*, clang::VarDecl*) SemaDecl.cpp:0:0
#21 0x0000000006aa40df clang::Sema::MergeVarDecl(clang::VarDecl*, clang::LookupResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6aa40df)
#22 0x0000000006aa550a clang::Sema::CheckVariableDeclaration(clang::VarDecl*, clang::LookupResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6aa550a)
#23 0x0000000006aa7a9d clang::Sema::ActOnVariableDeclarator(clang::Scope*, clang::Declarator&, clang::DeclContext*, clang::TypeSourceInfo*, clang::LookupResult&, llvm::MutableArrayRef<clang::TemplateParameterList*>, bool&, llvm::ArrayRef<clang::BindingDecl*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6aa7a9d)
#24 0x0000000006abcac4 clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6abcac4)
#25 0x0000000006abd530 clang::Sema::ActOnDeclarator(clang::Scope*, clang::Declarator&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6abd530)
#26 0x00000000067174be clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67174be)
#27 0x0000000006726f89 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6726f89)
#28 0x00000000066e6fae clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66e6fae)
#29 0x00000000066e776e clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66e776e)
#30 0x00000000066eef03 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66eef03)
#31 0x00000000066efded clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66efded)
#32 0x00000000066e230a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66e230a)
#33 0x0000000004560df8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4560df8)
#34 0x000000000481b949 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x481b949)
#35 0x000000000479abbe clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x479abbe)
#36 0x00000000049016de clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49016de)
#37 0x0000000000ce5b8f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xce5b8f)
#38 0x0000000000cdd84a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#39 0x00000000045a3f79 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
#40 0x0000000003b342a4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b342a4)
#41 0x00000000045a456f 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
#42 0x000000000456a8dd clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x456a8dd)
#43 0x000000000456b9cd 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+++0x456b9cd)
#44 0x0000000004572d85 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4572d85)
#45 0x0000000000ce2a29 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xce2a29)
#46 0x0000000000bafbc4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbafbc4)
#47 0x00007b7ccba29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#48 0x00007b7ccba29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#49 0x0000000000cdd2fe _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcdd2fe)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134

The issue can also be reproduced on Compiler Explorer:https://godbolt.org/z/e77c91afb

Please let me know if you need any more details.

@github-actions github-actions bot added the clang Clang issues not falling into any other category label Nov 4, 2024
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid] and removed clang Clang issues not falling into any other category labels Nov 4, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Nov 4, 2024

@llvm/issue-subscribers-clang-frontend

Author: Anonymous (iamanonymouscs)

### Description I encountered a crash in Clang-20 when compiling the following code snippet:
template&lt;int N&gt; struct A
{
    void foo() throw(int[N]);
};

A&lt;0&gt; a;

template&lt;typename T&gt; struct A
{
    void foo() throw(typename T::X);
};

A&lt;void&gt; a;

The compilation command used was:

clang++ -O3 -ffast-math -fno-ident -std=c++23 -fno-rtlib-add-rpath -Wall -Wextra -fno-strict-aliasing -fwrapv -g -fsanitize=address  test.cpp 

Following the error messages, the compiler crashed with an assertion failure:

TemplateArgument kind is not expected for NTTP UNREACHABLE executed at /root/llvm-project/clang/lib/AST/ASTDiagnostic.cpp:1245!

Error Message

&lt;source&gt;:3:16: error: ISO C++17 does not allow dynamic exception specifications [-Wdynamic-exception-spec]
    3 |     void foo() throw(int[N]);
      |                ^~~~~~~~~~~~~
&lt;source&gt;:3:16: note: use 'noexcept(false)' instead
    3 |     void foo() throw(int[N]);
      |                ^~~~~~~~~~~~~
      |                noexcept(false)
&lt;source&gt;:8:19: error: template parameter has a different kind in template redeclaration
    8 | template&lt;typename T&gt; struct A
      |                   ^
&lt;source&gt;:1:14: note: previous template declaration is here
    1 | template&lt;int N&gt; struct A
      |              ^
TemplateArgument kind is not expected for NTTP
UNREACHABLE executed at /root/llvm-project/clang/lib/AST/ASTDiagnostic.cpp:1245!
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/bin/clang++ -gdwarf-4 -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 -O3 -ffast-math -fno-ident -std=c++23 -fno-rtlib-add-rpath -Wall -Wextra -fno-strict-aliasing -fwrapv -g -fsanitize=address &lt;source&gt;
1.	&lt;source&gt;:13:10: current parser token ';'
 #<!-- -->0 0x0000000003be87b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3be87b8)
 #<!-- -->1 0x0000000003be64bc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3be64bc)
 #<!-- -->2 0x0000000003b33df8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #<!-- -->3 0x00007b7ccba42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #<!-- -->4 0x00007b7ccba969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #<!-- -->5 0x00007b7ccba42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #<!-- -->6 0x00007b7ccba287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #<!-- -->7 0x0000000003b3f71a (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b3f71a)
 #<!-- -->8 0x000000000793b6ce (anonymous namespace)::TemplateDiff::InitializeNonTypeDiffVariables(clang::ASTContext&amp;, (anonymous namespace)::TemplateDiff::TSTiterator const&amp;, clang::NonTypeTemplateParmDecl*, llvm::APSInt&amp;, bool&amp;, clang::QualType&amp;, bool&amp;, clang::Expr*&amp;, clang::ValueDecl*&amp;, bool&amp;) (.isra.0) ASTDiagnostic.cpp:0:0
 #<!-- -->9 0x000000000793bd4e (anonymous namespace)::TemplateDiff::DiffTemplate(clang::TemplateSpecializationType const*, clang::TemplateSpecializationType const*) ASTDiagnostic.cpp:0:0
#<!-- -->10 0x0000000007942cec FormatTemplateTypeDiff(clang::ASTContext&amp;, clang::QualType, clang::QualType, bool, bool, bool, bool, llvm::raw_ostream&amp;) ASTDiagnostic.cpp:0:0
#<!-- -->11 0x000000000794343c clang::FormatASTNodeDiagnosticArgument(clang::DiagnosticsEngine::ArgumentKind, long, llvm::StringRef, llvm::StringRef, llvm::ArrayRef&lt;std::pair&lt;clang::DiagnosticsEngine::ArgumentKind, long&gt;&gt;, llvm::SmallVectorImpl&lt;char&gt;&amp;, void*, llvm::ArrayRef&lt;long&gt;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x794343c)
#<!-- -->12 0x0000000003e12915 clang::Diagnostic::FormatDiagnostic(char const*, char const*, llvm::SmallVectorImpl&lt;char&gt;&amp;) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e12915)
#<!-- -->13 0x000000000487557a clang::TextDiagnosticPrinter::HandleDiagnostic(clang::DiagnosticsEngine::Level, clang::Diagnostic const&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x487557a)
#<!-- -->14 0x0000000003e1e1fb clang::DiagnosticIDs::EmitDiag(clang::DiagnosticsEngine&amp;, clang::DiagnosticBuilder const&amp;, clang::DiagnosticIDs::Level) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e1e1fb)
#<!-- -->15 0x0000000003e1e7f3 clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&amp;, clang::DiagnosticBuilder const&amp;) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e1e7f3)
#<!-- -->16 0x0000000003e11edf clang::DiagnosticsEngine::EmitDiagnostic(clang::DiagnosticBuilder const&amp;, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e11edf)
#<!-- -->17 0x0000000006869cc4 clang::Sema::EmitDiagnostic(unsigned int, clang::DiagnosticBuilder const&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6869cc4)
#<!-- -->18 0x00000000068e1a88 clang::SemaBase::ImmediateDiagBuilder::~ImmediateDiagBuilder() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x68e1a88)
#<!-- -->19 0x0000000006858a73 clang::SemaBase::SemaDiagnosticBuilder::~SemaDiagnosticBuilder() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6858a73)
#<!-- -->20 0x0000000006a80a43 diagnoseVarDeclTypeMismatch(clang::Sema&amp;, clang::VarDecl*, clang::VarDecl*) SemaDecl.cpp:0:0
#<!-- -->21 0x0000000006aa40df clang::Sema::MergeVarDecl(clang::VarDecl*, clang::LookupResult&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6aa40df)
#<!-- -->22 0x0000000006aa550a clang::Sema::CheckVariableDeclaration(clang::VarDecl*, clang::LookupResult&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6aa550a)
#<!-- -->23 0x0000000006aa7a9d clang::Sema::ActOnVariableDeclarator(clang::Scope*, clang::Declarator&amp;, clang::DeclContext*, clang::TypeSourceInfo*, clang::LookupResult&amp;, llvm::MutableArrayRef&lt;clang::TemplateParameterList*&gt;, bool&amp;, llvm::ArrayRef&lt;clang::BindingDecl*&gt;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6aa7a9d)
#<!-- -->24 0x0000000006abcac4 clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&amp;, llvm::MutableArrayRef&lt;clang::TemplateParameterList*&gt;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6abcac4)
#<!-- -->25 0x0000000006abd530 clang::Sema::ActOnDeclarator(clang::Scope*, clang::Declarator&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6abd530)
#<!-- -->26 0x00000000067174be clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&amp;, clang::Parser::ParsedTemplateInfo const&amp;, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67174be)
#<!-- -->27 0x0000000006726f89 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&amp;, clang::DeclaratorContext, clang::ParsedAttributes&amp;, clang::Parser::ParsedTemplateInfo&amp;, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6726f89)
#<!-- -->28 0x00000000066e6fae clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::ParsingDeclSpec&amp;, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66e6fae)
#<!-- -->29 0x00000000066e776e clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66e776e)
#<!-- -->30 0x00000000066eef03 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66eef03)
#<!-- -->31 0x00000000066efded clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&lt;clang::DeclGroupRef&gt;&amp;, clang::Sema::ModuleImportState&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66efded)
#<!-- -->32 0x00000000066e230a clang::ParseAST(clang::Sema&amp;, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66e230a)
#<!-- -->33 0x0000000004560df8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4560df8)
#<!-- -->34 0x000000000481b949 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x481b949)
#<!-- -->35 0x000000000479abbe clang::CompilerInstance::ExecuteAction(clang::FrontendAction&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x479abbe)
#<!-- -->36 0x00000000049016de clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49016de)
#<!-- -->37 0x0000000000ce5b8f cc1_main(llvm::ArrayRef&lt;char const*&gt;, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xce5b8f)
#<!-- -->38 0x0000000000cdd84a ExecuteCC1Tool(llvm::SmallVectorImpl&lt;char const*&gt;&amp;, llvm::ToolContext const&amp;) driver.cpp:0:0
#<!-- -->39 0x00000000045a3f79 void llvm::function_ref&lt;void ()&gt;::callback_fn&lt;clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const::'lambda'()&gt;(long) Job.cpp:0:0
#<!-- -->40 0x0000000003b342a4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref&lt;void ()&gt;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b342a4)
#<!-- -->41 0x00000000045a456f clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const (.part.0) Job.cpp:0:0
#<!-- -->42 0x000000000456a8dd clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&amp;, clang::driver::Command const*&amp;, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x456a8dd)
#<!-- -->43 0x000000000456b9cd clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x456b9cd)
#<!-- -->44 0x0000000004572d85 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4572d85)
#<!-- -->45 0x0000000000ce2a29 clang_main(int, char**, llvm::ToolContext const&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xce2a29)
#<!-- -->46 0x0000000000bafbc4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbafbc4)
#<!-- -->47 0x00007b7ccba29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#<!-- -->48 0x00007b7ccba29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#<!-- -->49 0x0000000000cdd2fe _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcdd2fe)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134

The issue can also be reproduced on Compiler Explorer:https://godbolt.org/z/e77c91afb

Please let me know if you need any more details.

@shafik
Copy link
Collaborator

shafik commented Nov 4, 2024

This looks like a clang trunk regression: https://godbolt.org/z/95Y6s569x

@shafik
Copy link
Collaborator

shafik commented Nov 5, 2024

@sdkrystian git bisect points to 2bb3d3a

@sdkrystian
Copy link
Member

@shafik Reduced to:

template<bool B> 
struct A { };

A<false> a;

template<typename T> 
struct A { };

A<void> a; // crash here

The crash seems to happen when emitting the template parameter/template argument "diff" in the redefinition of a. I can fix it by end of week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash Prefer [crash-on-valid] or [crash-on-invalid] regression
Projects
None yet
Development

No branches or pull requests

5 participants