Hi,

I am trying to use ViennaCL with Ceemple and encountered a possible bug.

In amg_base.hpp:1045, iter2 is decremented (code below). However, nothing
(at least locally in this function) prevents iter2 from
being pointlist.begin() and then the result is undefined, see

  http://stackoverflow.com/questions/18225651/is-stdvectorbegin-1-undefined

Also, why are both iter and iter2 required? it seems iter alone could do
the job.

Thanks, Yaron


Code:

            void add_influence(amg_point* point, unsigned int add)
            {
              ListType::iterator iter = pointlist.find(point);
              // If point is not in the list then stop.
              if (iter == pointlist.end()) return;

              // Save iterator and decrement
              ListType::iterator iter2 = iter;
              iter2--;

              // Point has to be erased first as changing the value does
not re-order the std::set
              pointlist.erase(iter);
              point->add_influence(add);

              // Insert point back into the list. Using the iterator
improves performance. The new position has to be at the same position or to
the right of the old.
              pointlist.insert(iter2,point);
            }
------------------------------------------------------------------------------
_______________________________________________
ViennaCL-devel mailing list
ViennaCL-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/viennacl-devel

Reply via email to