<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/112207>112207</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang++] Assertion `!OldParam->hasUnparsedDefaultArg()' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:frontend,
crash-on-invalid,
clang:frontend:fuzzer
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
yijan4845
</td>
</tr>
</table>
<pre>
**This testcase is generated by a fuzzer.**
Compiler Explorer: [https://godbolt.org/z/szKsjoef8](https://godbolt.org/z/szKsjoef8)
This invalid code will crash on Clang Assertion Trunk, it seems that this goes back to clang-7:
```cpp
class A {
template <typename T> class B {};
public:
template <typename T> class D {};
};
class E : public A {
template <typename T> void foo(A::D<T>, int v = v);
template <> void foo<A::B<char>>(A::D<A::B<char>>, int) {}
};
```
Stack dump:
```
clang++: /root/llvm-project/clang/lib/Parse/ParseCXXInlineMethods.cpp:477: void clang::Parser::ParseLexedMethodDeclaration(clang::Parser::LateParsedMethodDeclaration&): Assertion `!OldParam->hasUnparsedDefaultArg()' 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/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 <source>
1. <source>:10:2: current parser token ';'
2. <source>:7:1: parsing struct/union/class body 'E'
#0 0x0000000003ba9d48 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ba9d48)
#1 0x0000000003ba7a0c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ba7a0c)
#2 0x0000000003af4c68 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x0000717c83842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x0000717c838969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x0000717c83842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x0000717c838287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x0000717c8382871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x0000717c83839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x00000000066693f7 clang::Parser::ParseLexedMethodDeclaration(clang::Parser::LateParsedMethodDeclaration&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66693f7)
#10 0x000000000665e92d clang::Parser::ParseLexedMethodDeclarations(clang::Parser::ParsingClass&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x665e92d)
#11 0x00000000066b014f clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributes&, unsigned int, clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66b014f)
#12 0x00000000066b27a3 clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66b27a3)
#13 0x0000000006686fa0 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6686fa0)
#14 0x0000000006644494 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6644494)
#15 0x0000000006644efe clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6644efe)
#16 0x000000000664c693 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x664c693)
#17 0x000000000664d57d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x664d57d)
#18 0x000000000663fa9a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x663fa9a)
#19 0x0000000004502248 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4502248)
#20 0x00000000047bbb49 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47bbb49)
#21 0x000000000473a6ee clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x473a6ee)
#22 0x00000000048a16be clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48a16be)
#23 0x0000000000cdb8ef cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcdb8ef)
#24 0x0000000000cd35fa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#25 0x0000000004545f19 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
#26 0x0000000003af5114 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3af5114)
#27 0x000000000454650f 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
#28 0x000000000450be4d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x450be4d)
#29 0x000000000450cf3d 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+++0x450cf3d)
#30 0x0000000004514865 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4514865)
#31 0x0000000000cd87bf clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcd87bf)
#32 0x0000000000ba7d14 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xba7d14)
#33 0x0000717c83829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#34 0x0000717c83829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#35 0x0000000000cd30ae _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcd30ae)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWl9zm7gW_zTKiwYPCDD4IQ-OHe_tbnfa2eTe6ZtHiIOtLUhc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