public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/32883]  New: Regression: reverse_iterator produces valgrind errors
@ 2007-07-24 16:30 Raimund dot Merkert at baesystems dot com
  2007-07-24 16:40 ` [Bug c++/32883] " Raimund dot Merkert at baesystems dot com
  2007-07-24 16:54 ` pcarlini at suse dot de
  0 siblings, 2 replies; 3+ messages in thread
From: Raimund dot Merkert at baesystems dot com @ 2007-07-24 16:30 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/32883] Regression: reverse_iterator produces valgrind errors
  2007-07-24 16:30 [Bug c++/32883] New: Regression: reverse_iterator produces valgrind errors Raimund dot Merkert at baesystems dot com
@ 2007-07-24 16:40 ` Raimund dot Merkert at baesystems dot com
  2007-07-24 16:54 ` pcarlini at suse dot de
  1 sibling, 0 replies; 3+ messages in thread
From: Raimund dot Merkert at baesystems dot com @ 2007-07-24 16:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from Raimund dot Merkert at baesystems dot com  2007-07-24 16:40 -------
If I replace *i with ++i, I get basically the same result. It has struck me as
weird that this would be the "preferred way" according to Scott Myers, but
looking at the implementation bits/stl_iterator.h, this code should definitely
not work.

So, perhaps it is not a bug after all?


-- 


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/32883] Regression: reverse_iterator produces valgrind errors
  2007-07-24 16:30 [Bug c++/32883] New: Regression: reverse_iterator produces valgrind errors Raimund dot Merkert at baesystems dot com
  2007-07-24 16:40 ` [Bug c++/32883] " Raimund dot Merkert at baesystems dot com
@ 2007-07-24 16:54 ` pcarlini at suse dot de
  1 sibling, 0 replies; 3+ messages in thread
From: pcarlini at suse dot de @ 2007-07-24 16:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pcarlini at suse dot de  2007-07-24 16:54 -------
This code is invalid, as Carl Barron, Greg Herlihy and others explained very
carefully in that thread.


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-07-24 16:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-24 16:30 [Bug c++/32883] New: Regression: reverse_iterator produces valgrind errors Raimund dot Merkert at baesystems dot com
2007-07-24 16:40 ` [Bug c++/32883] " Raimund dot Merkert at baesystems dot com
2007-07-24 16:54 ` pcarlini at suse dot de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).