This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: libstdc++/7974: cannot reference an element of a vector in a class object from an iterator for a vector of such objects (the -> operator fails)
- From: paolo at gcc dot gnu dot org
- To: gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nixonj at agr dot gc dot ca, nobody at gcc dot gnu dot org, paolo at gcc dot gnu dot org
- Date: 31 Oct 2002 20:39:10 -0000
- Subject: Re: libstdc++/7974: cannot reference an element of a vector in a class object from an iterator for a vector of such objects (the -> operator fails)
- Reply-to: paolo at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nixonj at agr dot gc dot ca, nobody at gcc dot gnu dot org, paolo at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
Synopsis: cannot reference an element of a vector in a class object from an iterator for a vector of such objects (the -> operator fails)
Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-By: paolo
Responsible-Changed-When: Thu Oct 31 12:39:09 2002
Responsible-Changed-Why:
Triaged.
State-Changed-From-To: open->closed
State-Changed-By: paolo
State-Changed-When: Thu Oct 31 12:39:09 2002
State-Changed-Why:
User error.
In test::init you need 'resize' NOT 'reserve': only the former changes the size of the vector, whereas the latter
its capacity. Definitely, before *assigning* the elements
of the vector you need it to have two elements, *not* just
having it allocated raw memory capacity to grow to a
maximum size of two without reallocations.
I suggest reading C++PLSE, §16.3.8.
Thanks for your report, Paolo.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7974