From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7733 invoked by alias); 19 May 2004 17:32:36 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 7725 invoked by alias); 19 May 2004 17:32:35 -0000 Date: Thu, 20 May 2004 18:43:00 -0000 Message-ID: <20040519173235.7724.qmail@sourceware.org> From: "llewelly at xmission dot com" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20040518193757.15523.bangerth@dealii.org> References: <20040518193757.15523.bangerth@dealii.org> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug libstdc++/15523] Can't have vectors of vector::const_iterator X-Bugzilla-Reason: CC X-SW-Source: 2004-05/txt/msg02158.txt.bz2 List-Id: ------- Additional Comments From llewelly at xmission dot com 2004-05-19 17:32 ------- Subject: Re: Can't have vectors of vector::const_iterator "bangerth at dealii dot org" writes: > ------- Additional Comments From bangerth at dealii dot org 2004-05-19 14:24 ------- > I see your point, although 24.1/5 only speaks about "most operations" and > does not specifically rule out that we do the sensible thing here. I > think my point is that I fail to see the value of this check, since it > seems to be allowed to create such an iterator, but not to copy it. On > the other hand, if we simply omitted the check we would fall over later > if we ever tried to dereference it. The only thing that one would have > to make sure is that the result of assigning a singular iterator to > another iterator is again a singular iterator, but that should be what > happens anyway if we simply copy all member variables. > > I don't feel strongly either way, since I already fixed my code to > work around this, but I do feel that there are cases where one would > like to generate a vector of singular iterators, and only after that > assign individual values to them. The obvious answer is that if one can't initialize a vector of iterators to the 'right' value, one should initialize them to the null iterator. :-) (I know, pointers are the only iterators for which such a value exists.) 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. 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. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15523