From patchwork Tue Jun 4 14:28:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1943430 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=OYuCb2pN; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; 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 [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4VttJv1j3jz20Tb for ; Wed, 5 Jun 2024 00:29:35 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 87E0039702AE for ; Tue, 4 Jun 2024 14:29:33 +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.129.124]) by sourceware.org (Postfix) with ESMTPS id 376D739702A8 for ; Tue, 4 Jun 2024 14:29:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 376D739702A8 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 376D739702A8 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717511350; cv=none; b=mvgdeMHYJiW50XxFrHpoa1q/W4EfoswpiRGhkmdvu/XDzX5eNyDoP7Fo1QtB4+llizcNvwvwhEp8BV8rmuaI+hw/5oD/y70+5rTprgx4cHCwjHk4OlEFe1xPKRG2hjinVz4bVrMSezifR3+OHzlInTYBrT5mWvl4DSed/4r3z+Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717511350; c=relaxed/simple; bh=xup/sb2Yn40AdniCojNrJExHH8kp5awAy1AhayNZoNI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=T/a+LPmWIpZ4hhKDFHNNn6730jeEpQLgKnIGgBBnpns/SxJBFkjHR66drJJNgiYsNnuPTnoV34C/jUv31SPbGy64p7OgIVQs/NoogIvUpcNaVXiJF/FMfh4X4/tu2/7+DcQnbIkDtezYZQNHi5W8ZPHdlRb1WdsLsycoJNI4888= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717511348; 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=WodspUXXDnOocwUWCHZlsdqrNKmRwCeAYcTkDJlNn0c=; b=OYuCb2pN4QJ6o76fDBPZKML4An6HC4f41CXrsXmRqEAn2W8nzZNL7trVv9njW4bPDWjcr8 cuM5cOExI29OBXuDk8g0lScKE9GbSwjrsnnu79MEMHG2o7gHbV1VnGWVHRsuw/LkS0Uptw AaDdkhE79/J58Jk0iMUIbHKWVCujfak= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-515-pXFrYojsOtiaj8J4yB6XeQ-1; Tue, 04 Jun 2024 10:29:05 -0400 X-MC-Unique: pXFrYojsOtiaj8J4yB6XeQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 672913801F4C; Tue, 4 Jun 2024 14:29:05 +0000 (UTC) Received: from localhost (unknown [10.39.195.81]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1864C2022BC0; Tue, 4 Jun 2024 14:29:04 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Only define std::span::at for C++26 [PR115335] Date: Tue, 4 Jun 2024 15:28:41 +0100 Message-ID: <20240604142904.43190-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.1 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, 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 Tested x86_64-linux. Pushed to trunk. Will backport to gcc-14 too. -- >8 -- In r14-5689-g1fa85dcf656e2f I added std::span::at and made the correct changes to the __cpp_lib_span macro (with tests for the correct value in C++20/23/26). But I didn't make the declaration of std::span::at actually depend on the macro, so it was defined for C++20 and C++23, not only for C++26. This fixes that oversight. libstdc++-v3/ChangeLog: PR libstdc++/115335 * include/std/span (span::at): Guard with feature test macro. --- libstdc++-v3/include/std/span | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libstdc++-v3/include/std/span b/libstdc++-v3/include/std/span index 43e9cf82a54..00fc5279152 100644 --- a/libstdc++-v3/include/std/span +++ b/libstdc++-v3/include/std/span @@ -287,6 +287,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return *(this->_M_ptr + __idx); } +#if __cpp_lib_span >= 202311L // >= C++26 [[nodiscard]] constexpr reference at(size_type __idx) const @@ -296,6 +297,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION "of size %zu"), __idx, this->size()); return *(this->_M_ptr + __idx); } +#endif [[nodiscard]] constexpr pointer