This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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: libstdc++/8780: std::vector iterators not recognized as pointersby templates in certain cases


http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8780

Thanks for the report, but this is not a bug.

Any code that assumes that a vector<T>::iterator is a pointer is non-portable
and will break on many C++ implementations (including debug implementations,
which use extra fields in the iterator to detect dereferencing of out of range
iterators).


If you have code that makes such assumptions, then for cases where you know
that the iterator is not pointing to vec.end(), the construct &*iter will give
a valid pointer to the data (and you may portably assume that the data are
stored contiguously in the vector). A portable one-past-the-end pointer is
1+&vec.back() .



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