Szelethus added inline comments.

================
Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:1495-1496
 
   // For deque-like containers invalidate all iterator positions. For
   // vector-like containers invalidate iterator positions after the insertion.
   const auto *Cont = Pos->getContainer();
----------------
baloghadamsoftware wrote:
> Szelethus wrote:
> > >>! In D62525#1523026, @baloghadamsoftware wrote:
> > > For example, an insertion happens into a vector that invalidates all the 
> > > iterators at and after the position where it is inserted.
> > 
> > Is this actually correct?
> > 
> > https://en.cppreference.com/w/cpp/container/deque
> > > std::deque (double-ended queue) is an indexed sequence container that 
> > > allows fast insertion and deletion at both its beginning and its end. In 
> > > addition, insertion and deletion at either end of a deque never 
> > > invalidates pointers or references to the rest of the elements.
> > 
> > https://en.cppreference.com/w/cpp/container/vector
> > 
> > > `insert`, `emplace`, `resize`: If the vector changed capacity, all of the 
> > > iterators are invalidated. If not, only those after the insertion point.
> [[ https://en.cppreference.com/w/cpp/container/deque/insert | 
> https://en.cppreference.com/w/cpp/container/deque/insert ]]
> 
> //All iterators, including the past-the-end iterator, are invalidated.//
> 
> I think I speak here about `insert()`, not about `push_back()` and 
> `push_front()`.
> 
> Since we use a conservative approach we always assume that vectors and 
> double-end queues do not change capacities.
I stand corrected!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62525/new/

https://reviews.llvm.org/D62525



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to