<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/116385>116385</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [analyzer] alpha.cplusplus.InvalidatedIterator checker crashes on nonloc::LazyCompoundVal which is passed to SimpleConstraintManager.cpp
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          mostafa-mohammed-sonarsource
      </td>
    </tr>
</table>

<pre>
    The reduced code example:
```C++
// clang-19 --analyze -Xclang -analyzer-config -Xclang aggressive-binary-operation-simplification=true -Xclang -analyzer-checker=alpha.cplusplus.InvalidatedIterator -Xclang -analyzer-output=text
template < typename > class c {
public:
 class d {};
  class e {
    d f;
  };
  e end();
};

struct g {
  bool h;
};

template < typename > struct i {
  template < typename j > g operator==(j);
};

struct k {
  template < typename l > i< l > operator<<(l);
};

void o() {
  c< int > ints;
  auto q = k() << ints == ints.end();
}
```

crashes the analyzer.
when assertions are enabled, Compiler Explorer (clang 19 assertions): https://godbolt.org/z/sxb5deEjW
when assertions are disabled, Compiler Explorer (clang trunk): https://godbolt.org/z/555Pfvz1G


Stack trace:
```
'Assume' not implemented for this NonLoc
UNREACHABLE executed at /root/llvm-project/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp:68!
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-19.1.0/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-14.2.0 -fcolor-diagnostics -fno-crash-diagnostics --analyze -Xclang -analyzer-config -Xclang aggressive-binary-operation-simplification=true -Xclang -analyzer-checker=alpha.cplusplus.InvalidatedIterator -Xclang -analyzer-output=text <source>
1.      <eof> parser at end of file
2.      While analyzing stack: 
        #0 Calling o()
3.      <source>:24:12: Error evaluating statement
4.      <source>:24:12: Error evaluating statement
 #0 0x0000000003ae9978 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x3ae9978)
 #1 0x0000000003ae766c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x3ae766c)
 #2 0x0000000003a308f8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x000072c9d0c42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x000072c9d0c969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x000072c9d0c42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x000072c9d0c287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x0000000003a3c22a (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x3a3c22a)
 #8 0x000000000644ed2a clang::ento::SimpleConstraintManager::assumeAux(llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>, clang::ento::NonLoc, bool) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x644ed2a)
 #9 0x000000000644f095 clang::ento::SimpleConstraintManager::assume(llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>, clang::ento::NonLoc, bool) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x644f095)
#10 0x000000000644f2ba clang::ento::SimpleConstraintManager::assumeInternal(llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>, clang::ento::DefinedSVal, bool) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x644f2ba)
#11 0x00000000063508e8 std::pair<llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>, llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>> clang::ento::ConstraintManager::assumeDualImpl<clang::ento::ConstraintManager::assumeDual(llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>, clang::ento::DefinedSVal)::'lambda'(bool)>(llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>&, clang::ento::ConstraintManager::assumeDual(llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>, clang::ento::DefinedSVal)::'lambda'(bool)&) ConstraintManager.cpp:0:0
#12 0x0000000006350c14 clang::ento::ConstraintManager::assume(llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>, clang::ento::DefinedSVal, bool) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x6350c14)
#13 0x0000000005d8a4a0 clang::ento::ProgramState::assume(clang::ento::DefinedOrUnknownSVal, bool) const (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x5d8a4a0)
#14 0x0000000005f63c1d (anonymous namespace)::IteratorModeling::handleComparison(clang::ento::CheckerContext&, clang::Expr const*, clang::ento::SVal, clang::ento::SVal, clang::ento::SVal, clang::OverloadedOperatorKind) const (.isra.0) IteratorModeling.cpp:0:0
#15 0x0000000005f69314 (anonymous namespace)::IteratorModeling::checkPostCall(clang::ento::CallEvent const&, clang::ento::CheckerContext&) const IteratorModeling.cpp:0:0
#16 0x000000000634bde9 void expandGraphWithCheckers<(anonymous namespace)::CheckCallContext>((anonymous namespace)::CheckCallContext, clang::ento::ExplodedNodeSet&, clang::ento::ExplodedNodeSet const&) CheckerManager.cpp:0:0
#17 0x000000000634bfba clang::ento::CheckerManager::runCheckersForCallEvent(bool, clang::ento::ExplodedNodeSet&, clang::ento::ExplodedNodeSet const&, clang::ento::CallEvent const&, clang::ento::ExprEngine&, bool) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x634bfba)
#18 0x00000000063c05f1 clang::ento::ExprEngine::evalCall(clang::ento::ExplodedNodeSet&, clang::ento::ExplodedNode*, clang::ento::CallEvent const&) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x63c05f1)
#19 0x00000000063c1437 clang::ento::ExprEngine::VisitCallExpr(clang::CallExpr const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x63c1437)
#20 0x0000000006399f69 clang::ento::ExprEngine::Visit(clang::Stmt const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x6399f69)
#21 0x000000000639af75 clang::ento::ExprEngine::ProcessStmt(clang::Stmt const*, clang::ento::ExplodedNode*) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x639af75)
#22 0x00000000063a30fa clang::ento::ExprEngine::processCFGElement(clang::CFGElement, clang::ento::ExplodedNode*, unsigned int, clang::ento::NodeBuilderContext*) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x63a30fa)
#23 0x00000000063557fb clang::ento::CoreEngine::HandlePostStmt(clang::CFGBlock const*, unsigned int, clang::ento::ExplodedNode*) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x63557fb)
#24 0x0000000006355c3b clang::ento::CoreEngine::dispatchWorkItem(clang::ento::ExplodedNode*, clang::ProgramPoint, clang::ento::WorkListUnit const&) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x6355c3b)
#25 0x0000000006355d7a clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext const*, unsigned int, llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x6355d7a)
#26 0x0000000005d35621 (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
#27 0x0000000005d5c842 (anonymous namespace)::AnalysisConsumer::HandleDeclsCallGraph(unsigned int) AnalysisConsumer.cpp:0:0
#28 0x0000000005d5dee6 (anonymous namespace)::AnalysisConsumer::HandleTranslationUnit(clang::ASTContext&) AnalysisConsumer.cpp:0:0
#29 0x00000000064cc55c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x64cc55c)
#30 0x0000000004684f59 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x4684f59)
#31 0x0000000004609f8e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x4609f8e)
#32 0x000000000476e2be clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x476e2be)
#33 0x0000000000c82b7f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0xc82b7f)
#34 0x0000000000c7bcda ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#35 0x000000000443cba9 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
#36 0x0000000003a30da4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x3a30da4)
#37 0x000000000443d19f 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
#38 0x0000000004402c05 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x4402c05)
#39 0x000000000440366d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x440366d)
#40 0x000000000440b075 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0x440b075)
#41 0x0000000000c7fe95 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0xc7fe95)
#42 0x0000000000b547a4 main (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0xb547a4)
#43 0x000072c9d0c29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#44 0x000072c9d0c29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#45 0x0000000000c7b78e _start (/opt/compiler-explorer/clang-assertions-19.1.0/bin/clang+++0xc7b78e)
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/eJzkW99z26i3_2uUF0YeCcmS9ZAH13F2s7e7zTTd9r5lECCbBoEuoNTpX38HJCVCsd2kG3dmv99OmnH4cX58OOdwDmCkNdsISs-D-btgfnGGWrOV6ryW2qAKhbXcorqmJNRSIKVlqzA9KyV5OP-0pUBR0mJKAJaEArpDdcNpkCyD6CKIlkEWdT-rAL6zP10rvAzgJcAciU0YFyAMkUD84TsF4f-6RjA0qBBLUbHNYwfabBTVmt3TsGQCqYdQNlQhw6QINasbziqG3Z9BcmFUu5fkluI7qoLkAvFmi2a44a22_2dX4h5xRpCh5MpYslLtmS9b07TG0qc702lkaN1wZCgIkhUwDw0VqLZ_rK2SWgMMgrxXvmlLzvAjQv0A4gbkF0HSDwN9B32aCQAABFSjIf4ECqggAVwEsHhsHY_ofmujWmzAZky3lJKD7ZFJh_XrybExuf2jv7rxG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