<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/111609>111609</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang++] Assertion `parmDepth < FunctionTypeDepth.getDepth()' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</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/1cxsE9Pe8](https://godbolt.org/z/1cxsE9Pe8)
This valid code will crash on Clang Assertion Trunk, it seems that this goes back to clang 3.9:
```cpp
void test(unsigned char *b, int rb) {
typedef unsigned char imgfoo[rb];
static imgfoo &br = *(imgfoo *)b;
}
```
Stack dump:
```
clang++: /root/llvm-project/clang/lib/AST/ItaniumMangle.cpp:5815: void {anonymous}::CXXNameMangler::mangleFunctionParam(const clang::ParmVarDecl*): Assertion `parmDepth < FunctionTypeDepth.getDepth()' 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 -O3 <source>
1. <eof> parser at end of file
2. <source>:1:6: LLVM IR generation of declaration 'test'
3. <source>:1:6: Generating code for declaration 'test'
4. <source>:3:18: Mangling declaration 'br'
#0 0x0000000003b9d598 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b9d598)
#1 0x0000000003b9b25c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b9b25c)
#2 0x0000000003ae9a68 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x000079a486c42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000079a486c969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x000079a486c42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x000079a486c287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x000079a486c2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x000079a486c39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x0000000007d3562d (anonymous namespace)::CXXNameMangler::mangleFunctionParam(clang::ParmVarDecl const*) ItaniumMangle.cpp:0:0
#10 0x0000000007d38c2d (anonymous namespace)::CXXNameMangler::mangleExpression(clang::Expr const*, unsigned int, bool)::'lambda0'(clang::NamedDecl const*)::operator()(clang::NamedDecl const*) const (.isra.0) ItaniumMangle.cpp:0:0
#11 0x0000000007d322b9 (anonymous namespace)::CXXNameMangler::mangleExpression(clang::Expr const*, unsigned int, bool) ItaniumMangle.cpp:0:0
#12 0x0000000007d22875 (anonymous namespace)::CXXNameMangler::mangleType(clang::QualType) ItaniumMangle.cpp:0:0
#13 0x0000000007d226bf (anonymous namespace)::CXXNameMangler::mangleType(clang::QualType) ItaniumMangle.cpp:0:0
#14 0x0000000007d1f4be (anonymous namespace)::CXXNameMangler::mangleName(clang::GlobalDecl) ItaniumMangle.cpp:0:0
#15 0x0000000007d3b00e (anonymous namespace)::ItaniumMangleContextImpl::mangleCXXName(clang::GlobalDecl, llvm::raw_ostream&) ItaniumMangle.cpp:0:0
#16 0x0000000007d5ffd3 clang::MangleContext::mangleName(clang::GlobalDecl, llvm::raw_ostream&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7d5ffd3)
#17 0x0000000003fa1064 getMangledNameImpl(clang::CodeGen::CodeGenModule&, clang::GlobalDecl, clang::NamedDecl const*, bool) CodeGenModule.cpp:0:0
#18 0x0000000003fa788d clang::CodeGen::CodeGenModule::getMangledName(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fa788d)
#19 0x00000000043227fb clang::CodeGen::CodeGenModule::getOrCreateStaticVarDecl(clang::VarDecl const&, llvm::GlobalValue::LinkageTypes) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43227fb)
#20 0x0000000004323aea clang::CodeGen::CodeGenFunction::EmitStaticVarDecl(clang::VarDecl const&, llvm::GlobalValue::LinkageTypes) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4323aea)
#21 0x000000000432a3fb clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) (.part.0) CGDecl.cpp:0:0
#22 0x000000000432a696 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x432a696)
#23 0x0000000003ef03b7 clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ef03b7)
#24 0x0000000003f06fc9 clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f06fc9)
#25 0x0000000003efec65 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3efec65)
#26 0x0000000003f069e4 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f069e4)
#27 0x0000000003f6ee84 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f6ee84)
#28 0x0000000003f80e6c clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f80e6c)
#29 0x0000000003fe981a clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fe981a)
#30 0x0000000003fe4535 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fe4535)
#31 0x0000000003fe4aeb clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fe4aeb)
#32 0x0000000003feee63 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#33 0x00000000044f6806 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#34 0x00000000044e73e8 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44e73e8)
#35 0x0000000006620d04 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6620d04)
#36 0x00000000044f4378 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44f4378)
#37 0x00000000047ae299 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47ae299)
#38 0x000000000472cbde clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x472cbde)
#39 0x0000000004893b1e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4893b1e)
#40 0x0000000000cd805f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcd805f)
#41 0x0000000000ccfd6a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#42 0x0000000004538049 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
#43 0x0000000003ae9f14 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ae9f14)
#44 0x000000000453863f 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
#45 0x00000000044fdf7d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44fdf7d)
#46 0x00000000044ff06d 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+++0x44ff06d)
#47 0x0000000004506995 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4506995)
#48 0x0000000000cd4f2f clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcd4f2f)
#49 0x0000000000ba49e4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xba49e4)
#50 0x000079a486c29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#51 0x000079a486c29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#52 0x0000000000ccf81e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xccf81e)
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/eJzkWl1z46i2_TXKC2WXhL4f8uA4cd-e6rnTt5PqO28uJG3JmpZABSjtzK8_Bci2UOwkzolnztSZynRZCDZrLTabLYAIUVcU4NoJb5zw9or0csP49VP9B6FBEoRXGSuerh28cPDiYVMLJEHInAhAtUAVUOBEQoGyJ0RQ2f_5J_C5qey4t447_LtkbVc3wNHdtmsYB-74C-SENxspO-H4CwevHLyqWJGxRs4Zrxy8-tPBKy_firv0KyROeOvg5O3VcTruXuN-JE1doJwVgH7WTYNyTsQGMYqWDaEVWggBXNaMogfe0x8OXqJaIgHQCiQ3RCKpjFQMBMpI_gNJhnLd0J-nCpLpLnLNX951puSR1YWWzMFJT7XUBco3hCMHLzLdC5WIZw5OkRPfmEYIyacOCiiR3aRuq5IxJ7zhmRLE31cXksg6H94jB0cZR45_i_RIJPvihYPTbN_MiW8nqMea3UvFsujb7jk786jpO_hG_anhxCvOmHTwqmke21nH2R-Qq8eh3qqpMwevFvcPDl59loTWffsroVUDc6WWvwgTL1SGtGROfEMoo08t64UC6i8cf7H8_ff_JS2YVtyUtfph1dNcDd5Xwknr4CRnVEgzQKbaV8Lb74TfQt4YHVRPhzF3IrcjvL2FTm6Q4y_RzuDDUwe6dF6B1D8crN0Lx6gkdQPF3Kjx9cvd4v4OiT5ra4kIyvoKcegYl8pVJp5by02fzXPWDmo9F60Wogfh4BUitEA1zZu-ACQ3MPit8kHJSQ7KhToOHWc5CAEFEqznpli1JEKwvNZTlPcUiZzXnZyfHGJ37rjpV84qTlpEeNW3QKUYhpd1ejiHuTyD3VwehnhGdnKKmTRzaJXV9OABylPQrCp-El7OAjSr0Ex55Yp0nbLey66Xc4Fmr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