diff --git a/clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp @@ -228,7 +228,7 @@ Value = State->getRawSVal(*ValAsLoc); } - if (Value.isUnknownOrUndef()) + if (Value.isUnknownOrUndef() || !isa(Value)) return; // Incremention or decremention by 0 is never a bug. diff --git a/clang/test/Analysis/iterator-range.cpp b/clang/test/Analysis/iterator-range.cpp --- a/clang/test/Analysis/iterator-range.cpp +++ b/clang/test/Analysis/iterator-range.cpp @@ -946,3 +946,14 @@ // expected-warning@-1 {{The right operand of '-' is a garbage value}} // expected-note@-2 {{The right operand of '-' is a garbage value}} } + +namespace std { +namespace ranges { + template + InOutIter next(InOutIter, Sentinel); +} // namespace ranges +} // namespace std + +void gh65009__no_crash_on_ranges_next(int **begin, int **end) { + (void)std::ranges::next(begin, end); // no-crash +}