[PATCH] D25660: [Analyzer] Checker for iterators dereferenced beyond their range.

Artem Dergachev via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 1 14:19:08 PDT 2016


NoQ added inline comments.


================
Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:580
+  C.addTransition(stateFound);
+  C.addTransition(stateNotFound);
+}
----------------
NoQ wrote:
> Ouch, i have one more concern, which can be expressed with the following false-positive test which currently fails:
> 
> ```
> void foo() {
>   std::vector<int> vec;
>   vec.push_back(2016);
>   auto i = vec.find(vec.begin(), vec.end(), 2016);
>   *i; // no-warning
> }
> ```
> 
> Not instantly sure what to do with this. You can avoid state splits until you are actually sure if both branches are possible, but that'd suppress a lot of useful positives. Such positives could be suppressed with assertions, of course, but i'd still hope there aren't too many of those.
I mean, `std::find(...` ><


https://reviews.llvm.org/D25660





More information about the cfe-commits mailing list