From patchwork Fri Sep 6 20:50:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1982079 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=QdGQtVKW; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X0pRK3MKdz1y1D for ; Sat, 7 Sep 2024 06:55:57 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 620F0384A434 for ; Fri, 6 Sep 2024 20:55:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 26450385841D for ; Fri, 6 Sep 2024 20:55:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 26450385841D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 26450385841D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725656126; cv=none; b=d2OcrfUPuGqF3yfYEKmGp0p3Zhkai8cL0/GVBkHH/Wt3DhXXuqbaeW8wPzvVJowS3TckXRUI4i4xr8CwvD+eEhkIVzTo4/Pmg/Af5ac2Dn3UkbzhLd+sGVQo8ksgWyc71hbl8icCd/AJRpTEtWQiFMnlkDRlBfum/zmTKtzVn68= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725656126; c=relaxed/simple; bh=xhKF6arcB6D0OkxcUBD2DTORTK7bpkOBcdZLkhmiKpg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=rdUbKFPF2hcY4Rg1M+miNO8YzFLEl/zlatUlXFNVzWhqVTnLL+6ZubTLSgdEz+zB2IiqPP6Ex4clj0zM+hyNCUHYHXidwmBqRsnSiGa2jgwiyyHwLPt+vQPp9jN/V8yfI5xZIRI1zjWBAT5G7UTQbfxAXXOW+0crx8Iz5tzn6qQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725656124; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iKGwurnoQbvJiQoJe2cvs03geKhNfshmKfh7fRdx8dQ=; b=QdGQtVKWtWja0GyDm8gxT+uTWjA71DbLZVQM+TaY4Qmw5lZxlZ/dyxTt3n2P7SKgrR+pXe jOwPHBz3AIJjky1d9VNU5lAsXr02olHxZI4MVcthfOK+nCViErOFmJZboHyiyNb1gmhCIi krSm3nrug5RdLjFtn/eJO6KrEMZEw9A= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-370-rixzvkH2Pd6Hh-Tetrm-Wg-1; Fri, 06 Sep 2024 16:55:21 -0400 X-MC-Unique: rixzvkH2Pd6Hh-Tetrm-Wg-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6C1A919560AF; Fri, 6 Sep 2024 20:55:20 +0000 (UTC) Received: from localhost (unknown [10.42.28.101]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B832B19560AA; Fri, 6 Sep 2024 20:55:19 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] libstdc++: Adjust std::span::iterator to be ADL-proof Date: Fri, 6 Sep 2024 21:50:07 +0100 Message-ID: <20240906205518.3288989-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.5 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_H4, RCVD_IN_MSPIKE_WL, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org This proposed patch means that span is not an associated type of span::iterator, which means that we won't try to complete T when doing ADL in the constraints for const_iterator. This makes it more reliable to use std::span. See https://github.com/llvm/llvm-project/issues/107215 for more info on the problem and the constraint recursion that can happen. Does this seem worthwhile? It would be an ABI change to do something like this for other uses of __normal_iterator, such as std::vector and std::string. But std::span is a C++20 feature so still experimental. I think we should consider this for other new uses of __normal_iterator too, e.g. in . -- >8 -- libstdc++-v3/ChangeLog: * include/std/span (span::__iter_tag): Declare nested type. (span::iterator): Use __iter_tag as second template argument. --- libstdc++-v3/include/std/span | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/include/std/span b/libstdc++-v3/include/std/span index 00fc5279152..b7392a0500e 100644 --- a/libstdc++-v3/include/std/span +++ b/libstdc++-v3/include/std/span @@ -123,6 +123,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION using __is_compatible_ref = __is_array_convertible<_Type, remove_reference_t<_Ref>>; + // Nested type so that _Type is not an associated class of iterator. + struct __iter_tag; + public: // member types using element_type = _Type; @@ -133,7 +136,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION using const_pointer = const _Type*; using reference = element_type&; using const_reference = const element_type&; - using iterator = __gnu_cxx::__normal_iterator; + using iterator = __gnu_cxx::__normal_iterator; using reverse_iterator = std::reverse_iterator; #if __cplusplus > 202002L using const_iterator = std::const_iterator;