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.129.124]) by sourceware.org (Postfix) with ESMTPS id 0F4853858C52 for ; Tue, 10 Jan 2023 12:25:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0F4853858C52 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=1673353547; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=HhDoeX3vmWugPgApQOA3KukIgGhMraNRZxHYR/FNM5g=; b=AFULsbFM3zrD7NcR4e/k4HbpqS0sksUGyFWz7nqwa2/+LJl8ctGv2RNGEIxVhAfpsq+QtN lhZHrCD3tShPD3SHGdrFpzhVbBRygXmsZax/zwvVH/u/GYODxeNUsrEe9/hUkSwMGb5f1f n/BfeZXAnthlMIZrc9K3vhIB78hBPgM= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-397-L1ASdtd2Mt2TUiDAuJ5JVA-1; Tue, 10 Jan 2023 07:25:46 -0500 X-MC-Unique: L1ASdtd2Mt2TUiDAuJ5JVA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C189029AB3F9; Tue, 10 Jan 2023 12:25:45 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7C76B40C2004; Tue, 10 Jan 2023 12:25:38 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 30ACPam02744605 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 10 Jan 2023 13:25:36 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 30ACPZmc2744604; Tue, 10 Jan 2023 13:25:35 +0100 Date: Tue, 10 Jan 2023 13:25:35 +0100 From: Jakub Jelinek To: Jonathan Wakely Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [committed 1/3] libstdc++: Fix std::span constraint for sizeof(size_t) < sizeof(int) [PR108221] Message-ID: Reply-To: Jakub Jelinek References: <20230110114657.636853-1-jwakely@redhat.com> MIME-Version: 1.0 In-Reply-To: <20230110114657.636853-1-jwakely@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham 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 Tue, Jan 10, 2023 at 11:46:55AM +0000, Jonathan Wakely via Gcc-patches wrote: > Tested x86_64-linux. Pushed to trunk. > > -- >8 -- > > The default constructor has a constraint that is always false if > arithmetic on size_t values promotes to int. Rewrite the constraint > exactly as written in the standard, which works correctly. > > libstdc++-v3/ChangeLog: > > PR libstdc++/108221 > * include/std/span (span::span()): Un-simplify constraint to > work for size_t of lesser rank than int. > --- > libstdc++-v3/include/std/span | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libstdc++-v3/include/std/span b/libstdc++-v3/include/std/span > index 251fed91abf..b336332b190 100644 > --- a/libstdc++-v3/include/std/span > +++ b/libstdc++-v3/include/std/span > @@ -145,7 +145,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > > constexpr > span() noexcept > - requires ((_Extent + 1u) <= 1u) > + requires (_Extent == dynamic_extent || _Extent == 0) > : _M_ptr(nullptr), _M_extent(0) > { } If it would be C++23 only, you could use ((_Extent + 1uz) <= 1uz). As this is evaluated at compile time only, it is unfortunate it is 3 operations compared to former 2, but not a big deal. If this was in code that would be emitted at runtime, GCC already optimizes (x == -1uz || x == 0) or (x == 0 || x == -1uz) to ((x + 1uz) <= 1uz) Jakub