<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/152702>152702</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[analyzer] UNREACHABLE executed after saying "should always be wrapped in ArrayToPointerDecay"
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:static analyzer,
crash
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
k-arrows
</td>
</tr>
</table>
<pre>
Reproducer:
https://godbolt.org/z/a5T85h3nr
```cpp
struct A
{
int i[2];
};
struct B: A {};
void C()
{
const int &r = B().i[0];
}
```
Backtrace:
```console
should always be wrapped in ArrayToPointerDecay
UNREACHABLE executed at /root/llvm-project/llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:3554!
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 --analyze --std=c++98 <source>
1. <eof> parser at end of file
2. While analyzing stack:
#0 Calling C()
3. <source>:10:18: Error evaluating statement
4. <source>:10:18: Error evaluating statement
#0 0x0000000003ff2ff8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ff2ff8)
#1 0x0000000003ff0424 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ff0424)
#2 0x0000000003f34d18 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x0000762beb642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x0000762beb6969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x0000762beb642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x0000762beb6287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x0000000003f4037a (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f4037a)
#8 0x0000000006563680 clang::ento::ExprEngine::VisitMemberExpr(clang::MemberExpr const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6563680)
#9 0x0000000006568208 clang::ento::ExprEngine::Visit(clang::Stmt const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6568208)
#10 0x000000000656a8ad clang::ento::ExprEngine::ProcessStmt(clang::Stmt const*, clang::ento::ExplodedNode*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x656a8ad)
#11 0x000000000651f63b clang::ento::CoreEngine::HandlePostStmt(clang::CFGBlock const*, unsigned int, clang::ento::ExplodedNode*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x651f63b)
#12 0x000000000651fd28 clang::ento::CoreEngine::dispatchWorkItem(clang::ento::ExplodedNode*, clang::ProgramPoint, clang::ento::WorkListUnit const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x651fd28)
#13 0x0000000006520091 clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext const*, unsigned int, llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6520091)
#14 0x00000000060e8687 (anonymous namespace)::AnalysisConsumer::HandleCode(clang::Decl*, unsigned int, clang::ento::ExprEngine::InliningModes, llvm::DenseSet<clang::Decl const*, llvm::DenseMapInfo<clang::Decl const*, void>>*) AnalysisConsumer.cpp:0:0
#15 0x00000000060ea2be (anonymous namespace)::AnalysisConsumer::HandleDeclsCallGraph(unsigned int) AnalysisConsumer.cpp:0:0
#16 0x00000000060ebcc3 (anonymous namespace)::AnalysisConsumer::HandleTranslationUnit(clang::ASTContext&) AnalysisConsumer.cpp:0:0
#17 0x00000000066a510c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66a510c)
#18 0x0000000004c8ebd5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c8ebd5)
#19 0x0000000004c0aeae clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c0aeae)
#20 0x0000000004d83d01 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4d83d01)
#21 0x0000000000dae39f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdae39f)
#22 0x0000000000da500a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#23 0x0000000004a01d39 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
#24 0x0000000003f351b4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f351b4)
#25 0x0000000004a0234f 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
#26 0x00000000049c458d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49c458d)
#27 0x00000000049c561e 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+++0x49c561e)
#28 0x00000000049cd065 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49cd065)
#29 0x0000000000daa835 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdaa835)
#30 0x0000000000c5ece4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc5ece4)
#31 0x0000762beb629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#32 0x0000762beb629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#33 0x0000000000da4ab5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xda4ab5)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkWltz3CgW_jX4hVIXQpdWP_hBfZvJVGbWFXtmHrsQQt2sEagAOe359VsgtXWJnbU39mxtbSqJuwWc853vXDggE2P4UTJ2DZI1SLZXpLUnpa_vA6K1-mquClU-Xn9hjVZlS5kGUQ5QfrK2Me4j3gO8P6qyUMIulD4CvP8L4D1J7rLkFEkNUA5S1P2lTQNQbqxuqYVOCliuAcoh5NJCDpI1BskWRGs_cvnwtGANohzm0K0ZDT4oXsINwBnAq5FEqqSxXi7AqYYg2sJ1N2nhFKGJohHETuia0HurCWWdsYMBSholmMN0Uq0oIRFfyaOBBYNfNWkaVkIuYa41ebxTN4pLy_SWUfIIUP77b192-ebnfP15B9mZ0dayEhKHb6-VsgDvhXiog0arfzJ6-Qrw3iolDMB7Koh07ApeALy_tcRymksiHv9iGuD9RmkG8H53bvROHrlkC8d2lEdJEgMcApTffN7ltzto2qLmFhJYt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