This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] fix singular iterator dereference in libstdc++ testcase 23_containers/list_modifiers.cc


On Tue, Jun 10, 2003 at 02:28:53PM -0400, Stephen M. Webb wrote:
> On June 10, 2003 12:18 pm, Doug Gregor wrote:
> > On Tuesday, June 10, 2003, at 08:15 AM, Stephen M. Webb wrote:
> > > On June 9, 2003 06:21 pm, Doug Gregor wrote:
> > >
> > > The standard pretty explicitly states (in [23.2.2.3 (3)]) that
> > > pop_back()
> > > invalidates only iterators and references to the erased
> > > elements...
> >
> > The comments that pertain to iterator invalidation by container
> > operations only consider the "iterator" and "const_iterator" types for
> > a container, and not the "reverse_iterator" or "const_reverse_iterator"
> > types. Under this interpretation, the testcase is wrong, because it
> > fails when the latter two types are std::reverse_iterator<iterator> and
> 
> I'm having difficulty finding the text in the standard that excludes some of 
> the legitimate iterator types into a list in that clause.  Perhaps I'm 
> missing a DR that dealt with this issue.

I think what Doug is saying is that reverse_iterator is specified
to maintain a copy of an iterator one past that pointing to its
element; i.e. for element j, its member points to element j+1, 
and is thus invalidated when element j+1 goes away.  You cannot 
decrement an invalidated iterator, but that operation is required 
to dereference a reverse iterator on element j.  I don't think 
we have any local implemention semantics that makes this OK.

Nathan Myers
ncm-nospam@cantrip.org


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]