From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 8E41A3858C2D for ; Mon, 23 Jan 2023 18:25:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8E41A3858C2D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674498337; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mExVcI4lQNh5R7BecplAC5xFSMSzGCb+BMNko4e5jyo=; b=AhOy6E05t3dvwBdmpdGnZK/KQISRSGVEvZQpZkD4Rf91IR97FeS6y6I7wp6BhE1CZwFjQL 9dxObZIcu+aSrTwPKC8H+pQ0HqUjPuS5AuQ1/tx14NDsCgSeI0sYYeVVh1Kfak6XIUH+K0 gYNS2oWkNGa6scEE9Sh5znU85Y5rqek= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-616-WdWaZe1uNPG_LWbEMijRVQ-1; Mon, 23 Jan 2023 13:25:28 -0500 X-MC-Unique: WdWaZe1uNPG_LWbEMijRVQ-1 Received: by mail-lf1-f71.google.com with SMTP id w2-20020a0565120b0200b004cfd8133992so5339274lfu.11 for ; Mon, 23 Jan 2023 10:25:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mExVcI4lQNh5R7BecplAC5xFSMSzGCb+BMNko4e5jyo=; b=xOGsTejTFJ8EP75XkQAiTlPoA7eL5o8k6R5D7HSx6n+k8rQQCjfa5nulZQsZFy8jZn ucKWx9NNfiKzOx+k8mVsF8yivxf6lOlQJsQAmCECDkSWajifq+nIsQYAFkSEaYDPEJpb Iz/x+zr6OCizTNLznqtM7MTBCFoivxLKsOrtycVlGoI/DHH58L7oJo/mYqUZlBMn7Umn GqeUKMUV076CPhtDyzPGG087QJJ2OKSaH4esaKltk/KAKibWN0zfyVElU9Sn0jx3ySaV jJv6hlpfd1XCdmeDIRG37nff842CRE4mavpXgqijtOouYSjxWofw9hI+KJ+dQfifjgDI PQsQ== X-Gm-Message-State: AFqh2kqwYydV9A84cPdoYzdjE80fd0tvyHrPfQM0ZkGqpZfjZj9G0Htk siHFsmjG8/AuaCbRStMpwBJ93PJBVkN0iWeXQtRzMtlIxCZc7Fccw4+zfzE1zZLDUJOlg+DAkpq Z6TBi223fRijpXmeDu0773aNmUIR+lEk= X-Received: by 2002:a05:6512:3c8f:b0:4b0:65b0:7f30 with SMTP id h15-20020a0565123c8f00b004b065b07f30mr1285760lfv.385.1674498327288; Mon, 23 Jan 2023 10:25:27 -0800 (PST) X-Google-Smtp-Source: AMrXdXt9R9gM44wD4+qE5E4XqWUMuXru9hqqI5epWg0sz23VL8viq64j1NyxexdHrYP2XnvPLjLldG217yxoA+tMBnk= X-Received: by 2002:a05:6512:3c8f:b0:4b0:65b0:7f30 with SMTP id h15-20020a0565123c8f00b004b065b07f30mr1285758lfv.385.1674498327042; Mon, 23 Jan 2023 10:25:27 -0800 (PST) MIME-Version: 1.0 References: <290812af-847c-c6dd-3a56-fc51fc839dd3@gmail.com> In-Reply-To: <290812af-847c-c6dd-3a56-fc51fc839dd3@gmail.com> From: Jonathan Wakely Date: Mon, 23 Jan 2023 18:25:15 +0000 Message-ID: Subject: Re: [PATCH][_GLIBCXX_DEBUG] Remove useless checks To: =?UTF-8?Q?Fran=C3=A7ois_Dumont?= Cc: "libstdc++@gcc.gnu.org" , gcc-patches X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, 23 Jan 2023 at 18:15, Fran=C3=A7ois Dumont w= rote: > > On 23/01/23 10:22, Jonathan Wakely wrote: > > On Mon, 23 Jan 2023 at 06:02, Fran=C3=A7ois Dumont via Libstdc++ > > wrote: > >> libstdc++: [_GLIBCXX_DEBUG] Remove useless constructor checks > >> > >> Creating a safe iterator from a normal iterator is done within t= he > >> library where we > >> already know that it is done correctly. The rare situation where= a > >> user would use safe > >> iterators for his own purpose is non-Standard code so outside > >> _GLIBCXX_DEBUG scope. For > >> those reasons the __msg_init_singular is useless and can be remo= ved. > >> > >> Additionally in the copy constructor used for post-increment and > >> post-decrement operators > >> the __msg_init_copy_singular check can also be ommitted because = of > >> the preliminary > >> __msg_bad_inc and __msg_bad_dec checks. > >> > >> libstdc++-v3/ChangeLog: > >> > >> * include/debug/safe_iterator.h > >> (_Safe_iterator<>::_Unsafe_call): New. > > I don't like the name "unsafe call". Why is it unsafe? As you say > > above, we don't need to check because we know that it's only called in > > a context where it's safe. Can we call it _Unchecked instead of > > _Unsafe_call? That seems like a more accurate description of the > > behaviour. > > > > > >> (_Safe_iterator(const _Safe_iterator&, _Unsafe_call): Ne= w. > >> (_Safe_iterator::operator++(int)): Use latter. > >> (_Safe_iterator::operator--(int)): Likewise. > >> (_Safe_iterator(_Iterator, const _Safe_sequence_base*)): > >> Remove !_M_insular() > >> check. > >> * include/debug/safe_local_iterator.h > >> (_Safe_local_iterator<>::_Unsafe_call): > >> New. > >> (_Safe_local_iterator(const _Safe_local_iterator&, > >> _Unsafe_call): New. > >> (_Safe_local_iterator::operator++(int)): Use latter. > >> * src/c++11/debug.cc (_S_debug_messages): Add as comment > >> the _Debug_msg_id > >> entry associated to the array entry. > > These comments are a great idea, thanks. > > > > If you agree with the _Unchecked name, OK to commit with that change. > > > It's unsafe because it's unchecked so _Unchecked is fine for me too :-) But it doesn't need to be checked, because we know it's safe in all the places that it's used. So it's not unsafe :-) In some industries the words "safe" and "unsafe" have special meaning. Calling something "unsafe" when actually it's "safe by construction" will just raise red flags and unnecessary pain if an automated audit scans for the word "unsafe". Some poor person will have to fill out a form to say "it's not unsafe, it's just called that in the code" to be able to use the code. > Committed with the requested change. Great, thanks.