public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Joe Buck <jbuck@synopsys.com> To: paolo@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, Subject: Re: libstdc++/8780: std::vector iterators not recognized as pointers by templates in certain cases Date: Wed, 04 Dec 2002 10:26:00 -0000 [thread overview] Message-ID: <20021204182601.17574.qmail@sources.redhat.com> (raw) The following reply was made to PR libstdc++/8780; it has been noted by GNATS. From: Joe Buck <jbuck@synopsys.com> 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<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() .
next reply other threads:[~2002-12-04 18:26 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-12-04 10:26 Joe Buck [this message] -- strict thread matches above, loose matches on Subject: below -- 2002-12-04 10:24 paolo 2002-12-02 5:31 paolo 2002-12-02 1:06 johnb
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20021204182601.17574.qmail@sources.redhat.com \ --to=jbuck@synopsys.com \ --cc=gcc-prs@gcc.gnu.org \ --cc=paolo@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).