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)
paolo@gcc.gnu.org
paolo@gcc.gnu.org
Thu Oct 31 12:39:00 GMT 2002
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
More information about the Gcc-prs
mailing list