<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/122080>122080</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Assertion `getType(Base)->isPointerType() || getType(Base)->isArrayType()' failed
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
wxie7
</td>
</tr>
</table>
<pre>
code
```c
u8 b;
extern short b[];
extern signed char c[];
int main() {
for (long j = 3; j < 1024; j += 3)
if (c[j] ? b[j] : 0)
}
```
just crash on assertion trunk
https://godbolt.org/z/ovMj7TePr
same assertion message https://github.com/llvm/llvm-project/issues/120085
<details><summary><strong>Backtrace</strong></summary>
<p>
```
clang: /root/llvm-project/clang/lib/AST/ExprConstant.cpp:1747: void {anonymous}::LValue::addUnsizedArray({anonymous}::EvalInfo&, const clang::Expr*, clang::QualType): Assertion `getType(Base)->isPointerType() || getType(Base)->isArrayType()' 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 -x c -std=c2x -c <source>
1. <source>:6:24: current parser token ')'
2. <source>:4:12: parsing function body 'main'
3. <source>:4:12: in compound statement ('{}')
#0 0x0000000003c8d758 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c8d758)
#1 0x0000000003c8b464 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c8b464)
#2 0x0000000003bd89a8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x0000717f76242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x0000717f762969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x0000717f76242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x0000717f762287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x0000717f7622871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x0000717f76239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x00000000077b21e2 (anonymous namespace)::LValue::addUnsizedArray((anonymous namespace)::EvalInfo&, clang::Expr const*, clang::QualType) ExprConstant.cpp:0:0
#10 0x000000000782bc82 (anonymous namespace)::PointerExprEvaluator::VisitCastExpr(clang::CastExpr const*) ExprConstant.cpp:0:0
#11 0x00000000077df5ba clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous namespace)::PointerExprEvaluator, bool>::Visit(clang::Stmt const*) ExprConstant.cpp:0:0
#12 0x00000000077e14cb EvaluatePointer(clang::Expr const*, (anonymous namespace)::LValue&, (anonymous namespace)::EvalInfo&, bool) ExprConstant.cpp:0:0
#13 0x00000000077e4298 (anonymous namespace)::LValueExprEvaluator::VisitArraySubscriptExpr(clang::ArraySubscriptExpr const*) ExprConstant.cpp:0:0
#14 0x00000000077f3125 clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous namespace)::LValueExprEvaluator, bool>::Visit(clang::Stmt const*) ExprConstant.cpp:0:0
#15 0x00000000077f4e7d EvaluateLValue(clang::Expr const*, (anonymous namespace)::LValue&, (anonymous namespace)::EvalInfo&, bool) ExprConstant.cpp:0:0
#16 0x00000000077ca08e Evaluate(clang::APValue&, (anonymous namespace)::EvalInfo&, clang::Expr const*) ExprConstant.cpp:0:0
#17 0x00000000077d2ddb EvaluateAsRValue((anonymous namespace)::EvalInfo&, clang::Expr const*, clang::APValue&) ExprConstant.cpp:0:0
#18 0x00000000077d5fa7 clang::Expr::EvaluateAsRValue(clang::Expr::EvalResult&, clang::ASTContext const&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x77d5fa7)
#19 0x000000000686b153 TryGetExprRange(clang::ASTContext&, clang::Expr const*, unsigned int, bool, bool) SemaChecking.cpp:0:0
#20 0x0000000006893ce2 clang::Sema::CheckImplicitConversion(clang::Expr*, clang::QualType, clang::SourceLocation, bool*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6893ce2)
#21 0x0000000006896f7e CheckConditionalOperator(clang::Sema&, clang::AbstractConditionalOperator*, clang::SourceLocation, clang::QualType) SemaChecking.cpp:0:0
#22 0x0000000006897693 AnalyzeImplicitConversions(clang::Sema&, clang::Expr*, clang::SourceLocation, bool) (.constprop.0) SemaChecking.cpp:0:0
#23 0x0000000006898fcd clang::Sema::CheckCompletedExpr(clang::Expr*, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6898fcd)
#24 0x0000000006c3af1c clang::Sema::ActOnFinishFullExpr(clang::Expr*, clang::SourceLocation, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6c3af1c)
#25 0x0000000006b58ebe clang::Sema::ActOnCondition(clang::Scope*, clang::SourceLocation, clang::Expr*, clang::Sema::ConditionKind, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6b58ebe)
#26 0x000000000672745e clang::Parser::ParseParenExprOrCondition(clang::ActionResult<clang::Stmt*, true>*, clang::Sema::ConditionResult&, clang::SourceLocation, clang::Sema::ConditionKind, clang::SourceLocation&, clang::SourceLocation&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x672745e)
#27 0x0000000006730356 clang::Parser::ParseIfStatement(clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6730356)
#28 0x0000000006729418 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6729418)
#29 0x000000000672ab30 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x672ab30)
#30 0x000000000672d388 clang::Parser::ParseStatement(clang::SourceLocation*, clang::Parser::ParsedStmtContext) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x672d388)
#31 0x000000000672dc18 clang::Parser::ParseForStatement(clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x672dc18)
#32 0x000000000672943f clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x672943f)
#33 0x000000000672ab30 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x672ab30)
#34 0x000000000672b9f5 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x672b9f5)
#35 0x000000000672d1fa clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x672d1fa)
#36 0x000000000663f4c3 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x663f4c3)
#37 0x000000000667407d 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+0x667407d)
#38 0x000000000663322e clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x663322e)
#39 0x00000000066339e9 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x66339e9)
#40 0x000000000663b193 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x663b193)
#41 0x000000000663c06d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x663c06d)
#42 0x000000000662e4ca clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x662e4ca)
#43 0x000000000461f2b8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x461f2b8)
#44 0x00000000048dbab9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x48dbab9)
#45 0x000000000485e18e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x485e18e)
#46 0x00000000049c906e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x49c906e)
#47 0x0000000000ceda5f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xceda5f)
#48 0x0000000000ce54fa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#49 0x0000000004664e49 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
#50 0x0000000003bd8e54 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3bd8e54)
#51 0x000000000466543f 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
#52 0x000000000462902d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x462902d)
#53 0x000000000462a0ae 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+0x462a0ae)
#54 0x0000000004631bd5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4631bd5)
#55 0x0000000000cea8a3 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xcea8a3)
#56 0x0000000000bb6b84 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbb6b84)
#57 0x0000717f76229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#58 0x0000717f76229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#59 0x0000000000ce4fa5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xce4fa5)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
</p>
</details>
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsW11zpDYW_TXyi6pdIL4f_IDb7qyzk7J32pvXLiFEmzFIrCQ87fz6LUnQNPSH7Zl2NlWbVFJpg3R17rlHVxchsJTlmlF6BYJrENxc4FY9cXH1fVPS6CLj-esV4TkFTgpCx_5LgJO2McyAdw2clG4UFQzKJy4UzKyR8R1tPofkCQtIdu-XTMEalwygGKAEgkhfhLDgAgIUV5yt4TcIvBvoAe_a_JxD10F-9xe6tvdQYrpBWBa6nx7iGwhuIPAWBk_3Rwod2xREN7veACf91koFicDyCXIGsZRUqJIzqETLnoGTPinVSOClAC0AWqx5nvFKXXKxBmjxB0AL_vLbt-iRPgjgpBLXdMdETaXEawonJkr11GaXhNcALarqpf_frBH8GyUKoEUpZUslQAsXOU4caMROCrx5ThUuKwm8W-DNZVvXWLx2fyjB2Rp4t9eYPCuBCQXeHKDF9nr359DHGGy6X2NKSIV1nxQCtBCcq32AtgVaVGUG0CJdPgK0uN00Ys6ZVJipS9I0wEvdyI-0nRde5jrEmHH2WvNW6jB4KfDSL7_jqqX2N87zfzNZ_kHzVAj8qpVxqMvtC67uWMEBCgGaQ6KHhD1kfX_TCIBSc2-4-q8WV4-vDdUy8FKYboMEQmdNlb0VX2OpW8yAd1vKB14yRUV3y6p0DqI5PNLeoB5aAxTBApcVzS-Bkz58uU2Xt1C2WV0qiGHWrqGgjZ43iv-EQiBmOSwZqdqcQvVEOylnWxmgOWwEbQQnVEqaQ8lbYS_rnlhKTkqsaA5Fy6AkomyUxrtUmDzDvK11HIGTOpfASR4EXwtcQyzWbU2Zkp1IeGNEweumrKiY0U1TcUFFL5TZdkrImZ1WaJHpqW9vw9k6_45FMfPhbA1nXFvETaPttqpp1aWEs1r7D2ezTRzOsKxn8pUpvAHejQ5RBWcF47MXKjIuqb4PZ0s4m60JmSnOK_KkE413cxKpbiwZbuQTV3BWEF5xMctLvGZcqpJIO4Zh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