public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: llewelly@xmission.com To: gcc-bugzilla@gcc.gnu.org Cc: gcc-bugs@gcc.gnu.org Subject: Re: [Bug libstdc++/15523] Can't have vectors of vector::const_iterator Date: Thu, 20 May 2004 18:43:00 -0000 [thread overview] Message-ID: <s3rlljomg48.fsf@xmission.xmission.com> (raw) In-Reply-To: <20040519173954.13370.qmail@sourceware.org> "bangerth at ices dot utexas dot edu" <gcc-bugzilla@gcc.gnu.org> writes: > ------- Additional Comments From bangerth at ices dot utexas dot edu 2004-05-19 17:39 ------- > Subject: Re: Can't have vectors of vector::const_iterator > > > > I think in most cases it would be sufficient to create an empty > > vector, set it its vector<>::capacity(), and then push_back() new > > values into it. > > That's exactly what I ended up doing in our code. > > > > My naive expectation would be that -D_GLIBCXX_DEBUG_PEDANTIC would > > cause an abort() for all dectectable undefined behavior. I think > > most other users would expect this as well, *but* many probably > > don't realize this extends to aborting on the copy of a singular > > iterator, much less to aborting on the creation of the vector full > > of singular iterators. OTOH, some users expect implementations to > > report errors they don't know about. > > As I said, I don't feel strongly way, I'm just confused because I don't see a > reaonsing behind this particular check. What harm does it do to copy an > object that you will not be allowed to use anyway? I can only speculate as to the reasoning behind the check, but the example is undefined behavior. The check prevents an unsuspecting user from writing code which may misbehave on another implementation. In theory, such code may not be portable to other implementations. In practice, I don't know of an implementation in which copying an invalid iterator is a significant problem. But then, I mostly only use libstdc++ . :-) I don't really know how far libstdc++ should go in emitting errors for non-conforming code. I did expect -D_GLIBCXX_DEBUG_PEDANTIC to cause that abort, and mildly prefer that it continue to do so, but I don't know how other users would react to it. > Since the standard says > that behavior is undefined, we have some leeway in implementing sensible > behavior, in particular since we know that this can never hurt > anyone. I don't see this as being about whether gcc can implement sensible behavior for this case. My question is, should libstdc++ emit an error for this case, because some *other* implementation may not implement a sensible behavior for this case? The safe answer seems to be yes, but if nobody knows of an implementation where copying invalid pointers or iterators has bad behavior, maybe it's just paranoia. > > But I'm fine if we decide that this is NAD and that we should close this PR. > Please feel free to do so if you want. I'm just an overly talkative observer. I don't close bugs. :-)
next prev parent reply other threads:[~2004-05-19 18:22 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2004-05-19 12:25 [Bug libstdc++/15523] New: " bangerth at dealii dot org 2004-05-19 13:00 ` [Bug libstdc++/15523] " pinskia at gcc dot gnu dot org 2004-05-19 22:58 ` [Bug libstdc++/15523] New: " llewelly 2004-05-19 23:07 ` [Bug libstdc++/15523] " llewelly at xmission dot com 2004-05-20 15:16 ` bangerth at dealii dot org 2004-05-20 18:43 ` llewelly 2004-05-20 18:43 ` bangerth at ices dot utexas dot edu 2004-05-20 18:43 ` llewelly [this message] 2004-05-20 18:43 ` llewelly at xmission dot com 2004-05-20 18:43 ` sebor at roguewave dot com 2004-05-21 6:17 ` llewelly 2004-05-20 18:43 ` llewelly at xmission dot com 2004-05-20 19:27 ` bangerth at ices dot utexas dot edu 2004-05-21 9:21 ` llewelly at xmission dot com 2004-05-25 14:33 ` bkoz at gcc dot gnu dot org 2004-06-20 6:53 ` [Bug libstdc++/15523] [DR 408] " pinskia at gcc dot gnu dot org 2004-06-20 6:53 ` pinskia at gcc dot gnu dot org 2005-01-13 13:30 ` polzin_spamprotect_ at gmx dot de
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=s3rlljomg48.fsf@xmission.xmission.com \ --to=llewelly@xmission.com \ --cc=gcc-bugs@gcc.gnu.org \ --cc=gcc-bugzilla@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).