From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 73775 invoked by alias); 19 Sep 2015 09:12:26 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 73754 invoked by uid 89); 19 Sep 2015 09:12:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-yk0-f176.google.com Received: from mail-yk0-f176.google.com (HELO mail-yk0-f176.google.com) (209.85.160.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sat, 19 Sep 2015 09:12:24 +0000 Received: by ykft14 with SMTP id t14so66564359ykf.0; Sat, 19 Sep 2015 02:12:22 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.129.103.67 with SMTP id b64mr8192466ywc.55.1442653942026; Sat, 19 Sep 2015 02:12:22 -0700 (PDT) Received: by 10.37.207.208 with HTTP; Sat, 19 Sep 2015 02:12:21 -0700 (PDT) In-Reply-To: <55FD0F35.4010106@gmail.com> References: <55F71189.8080006@gmail.com> <20150914195038.GQ2631@redhat.com> <55F9C4F6.6030706@gmail.com> <20150916202953.GE2631@redhat.com> <55FD0F35.4010106@gmail.com> Date: Sat, 19 Sep 2015 09:48:00 -0000 Message-ID: Subject: Re: vector lightweight debug mode From: Jonathan Wakely To: =?UTF-8?Q?Fran=C3=A7ois_Dumont?= Cc: Jonathan Wakely , "libstdc++@gcc.gnu.org" , gcc-patches Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2015-09/txt/msg01474.txt.bz2 On 19 September 2015 at 08:31, Fran=C3=A7ois Dumont wrote: > On 16/09/2015 22:29, Jonathan Wakely wrote: >> No, because it is undefined to compare iterators that belong to >> different containers, or to compare pointers that point to different >> arrays. >> > > (Written before Christopher reply:) > > At least program will compile only if iterator is coming from a vector > of the same type. So behavior is undefined only if user pass an invalid > iterator which is exactly what this check tries to detect, isn't it > paradoxical ? If this undefined behavior results in the program abortion > this is what should happen anyway. If it doesn't abort then the program > will definitely not behaves as expected so this check doesn't make > anything worst, no ? The problem is that undefined behaviour can "travel backwards in time". It's not as simple as saying that if the invalid check happens _then_ undefined behaviour happens afterwards. However, Google seem to find these checks useful, and you and Chris are in favour, so let's keep them.