From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17589 invoked by alias); 4 Dec 2002 18:26:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 17575 invoked by uid 71); 4 Dec 2002 18:26:01 -0000 Date: Wed, 04 Dec 2002 10:26:00 -0000 Message-ID: <20021204182601.17574.qmail@sources.redhat.com> To: paolo@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Joe Buck Subject: Re: libstdc++/8780: std::vector iterators not recognized as pointers by templates in certain cases Reply-To: Joe Buck X-SW-Source: 2002-12/txt/msg00226.txt.bz2 List-Id: The following reply was made to PR libstdc++/8780; it has been noted by GNATS. From: Joe Buck To: gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, johnb@stl.sarov.ru, gcc-bugs@gcc.gnu.org, paolo@gcc.gnu.org Cc: Subject: Re: libstdc++/8780: std::vector iterators not recognized as pointers by templates in certain cases Date: Wed, 04 Dec 2002 10:21:03 -0800 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::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() .