When this code is run with : valgrind --tool=memcheck a.out 5 it produces quite
a few errors. I confirmed this with 4.2.0. The problem is not present in 3.2.2.
Valgrind version is 3.2.3:

#include <set>

using namespace std;

int main()
{
  set<int> c;
  c.insert(1);
  c.insert(2);
  c.insert(3);
  c.insert(4);

  set<int>::reverse_iterator i = c.rbegin();
  c.erase((++i).base());
  *i;
  return 0;
}

A collegue of mine who actually encountered this problem had posted about it
here: 
http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/402c7fb95f649314/a58fd22549a56fca


-- 
           Summary: Regression: reverse_iterator produces valgrind errors
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Raimund dot Merkert at baesystems dot com
  GCC host triplet: g++ (GCC) 3.4.3 20050227 (Red Hat 3.4.3-22.1)


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32883

Reply via email to