[committed] libstdc++: Add const to hash<coroutine_handle<P>>::operator() [PR109165]
Message ID | 20230317203601.55027-1-jwakely@redhat.com |
---|---|
State | Repeat Merge |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp549411wrt; Fri, 17 Mar 2023 13:37:08 -0700 (PDT) X-Google-Smtp-Source: AK7set++TbbfZUXsZj6L0/5SD2CLlxwdVxWJBvCdg6TQk6VODPioq89KGgtjaj6wIMSqeYRalCrX X-Received: by 2002:aa7:d287:0:b0:4fe:9555:3a57 with SMTP id w7-20020aa7d287000000b004fe95553a57mr4582476edq.16.1679085428733; Fri, 17 Mar 2023 13:37:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679085428; cv=none; d=google.com; s=arc-20160816; b=0TdOxrSL8H1YMjs9hvePGOFaJp+AZWsNQYQcmkXDujnTjjKNwAQSpvlZk/HXXhgvHU QwpVWGr09MJJ11Huqe746pKZpsK1jH7yUqqB8Lr+YabFfK3f+LRelJF4Hrlk7WQ0c2en OjfK/GC7iLCqL7NMURnyffJZOvlHhmr9VdStUDa6eEYnnh3cxqMMRP66sie9vBnTw72v ehxWeJ0xERyUVLnIYQLH1zlC6/trLzVmqw0+WiULsCleZppaTWhyFmMI350X47/gSuft P75ItKeBJdejmTLG/h1ZjV+DQ8I6liss0OUU/bp+VeK1CaFRIIapsDYm9UJY98Tdn3q6 6tjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=Nl6hZFwJsayJutTA5abDLe8p3jJ5G4IFDrnoMQlG0Ks=; b=J+w1uP+asEqdcmYaqzNwDAyEk4cgM1IgiEh7cvtnkTaaVRNQT58cHlFZQKmlNxrFcA y7oRWXuGQZ1rMCFNqeN3SlSoES/VgTeKMam1YqjnxB62o3EFfjbtfR93XWZ0zxthqE3u RJuzTL0RRHgnHj5WXadAfVirxfNQB2VkHG7yco9I0KSHofV2bvSQDPBQN9bwovaqJXfk e8YhDNxfr/iZkLhzl02S3NKhl85SP4RtSGopLLCeYNXhKSS2W4G8gvQenAdjlNPg0KQZ dviYhVkTIm9xq7SOzO16i6stawl9Yb1gcNY2G9nACVOU0ULJsmhIzYAu0VBx76O45iUk 1Neg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=JoJ8kVs1; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id g22-20020aa7d1d6000000b004bf976a1b56si3549972edp.627.2023.03.17.13.37.08 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Mar 2023 13:37:08 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=JoJ8kVs1; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8B383385087E for <ouuuleilei@gmail.com>; Fri, 17 Mar 2023 20:36:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8B383385087E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679085409; bh=Nl6hZFwJsayJutTA5abDLe8p3jJ5G4IFDrnoMQlG0Ks=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=JoJ8kVs1LHK3w4u72iouFd6LK+ms0U9H4eot2aO+amwip9ga1LnFnBbZZfPQqC88m QdudaVrJu7ilt9yLlDqOZVtXLT0OR7dET08yAR7f9d0cZ3qFVmOOOt9sf4g3rblrAV 3n0pmUb0FNkTS0e5rruQyK7+vK3RCmZY7JcAPXe4= 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 B8ACB385085C for <gcc-patches@gcc.gnu.org>; Fri, 17 Mar 2023 20:36:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B8ACB385085C 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-595-wi6GyIB1OtaM8R96tseH-w-1; Fri, 17 Mar 2023 16:36:02 -0400 X-MC-Unique: wi6GyIB1OtaM8R96tseH-w-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8A0151C05134; Fri, 17 Mar 2023 20:36:02 +0000 (UTC) Received: from localhost (unknown [10.33.36.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 52AD2140E991; Fri, 17 Mar 2023 20:36:02 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Add const to hash<coroutine_handle<P>>::operator() [PR109165] Date: Fri, 17 Mar 2023 20:36:01 +0000 Message-Id: <20230317203601.55027-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit 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_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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Jonathan Wakely via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Jonathan Wakely <jwakely@redhat.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760648682020830717?= X-GMAIL-MSGID: =?utf-8?q?1760648682020830717?= |
Series |
[committed] libstdc++: Add const to hash<coroutine_handle<P>>::operator() [PR109165]
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | warning | Git am fail log |
Commit Message
Jonathan Wakely
March 17, 2023, 8:36 p.m. UTC
Tested x86_64-linux. Pushed to trunk. gcc-12 backport needed too. -- >8 -- libstdc++-v3/ChangeLog: PR libstdc++/109165 * include/std/coroutine (hash<>::operator()): Add const. * testsuite/18_support/coroutines/hash.cc: New test. --- libstdc++-v3/include/std/coroutine | 2 +- .../testsuite/18_support/coroutines/hash.cc | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 libstdc++-v3/testsuite/18_support/coroutines/hash.cc
Comments
On Sat, Mar 18, 2023 at 7:36 AM Jonathan Wakely via Libstdc++ <libstdc++@gcc.gnu.org> wrote: > > Tested x86_64-linux. Pushed to trunk. gcc-12 backport needed too. > > -- >8 -- > > libstdc++-v3/ChangeLog: > > PR libstdc++/109165 > * include/std/coroutine (hash<>::operator()): Add const. > * testsuite/18_support/coroutines/hash.cc: New test. > --- > libstdc++-v3/include/std/coroutine | 2 +- > .../testsuite/18_support/coroutines/hash.cc | 22 +++++++++++++++++++ > 2 files changed, 23 insertions(+), 1 deletion(-) > create mode 100644 libstdc++-v3/testsuite/18_support/coroutines/hash.cc > > diff --git a/libstdc++-v3/include/std/coroutine b/libstdc++-v3/include/std/coroutine > index f6e65566f10..b0ca18949db 100644 > --- a/libstdc++-v3/include/std/coroutine > +++ b/libstdc++-v3/include/std/coroutine > @@ -345,7 +345,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > struct hash<coroutine_handle<_Promise>> > { > size_t > - operator()(const coroutine_handle<_Promise>& __h) noexcept > + operator()(const coroutine_handle<_Promise>& __h) const noexcept > { > return reinterpret_cast<size_t>(__h.address()); > } > diff --git a/libstdc++-v3/testsuite/18_support/coroutines/hash.cc b/libstdc++-v3/testsuite/18_support/coroutines/hash.cc > new file mode 100644 > index 00000000000..68e5e640477 > --- /dev/null > +++ b/libstdc++-v3/testsuite/18_support/coroutines/hash.cc > @@ -0,0 +1,22 @@ > +// { dg-options "-std=gnu++2a" } > +// { dg-do run { target c++2a } } > + > +#include <coroutine> > +#include <testsuite_hooks.h> > + > +void > +test01() > +{ > + std::hash<std::noop_coroutine_handle> h; > + std::size_t v = h(std::noop_coroutine()); > + > + const auto& ch = h; > + std::size_t v2 = h(std::noop_coroutine()); // PR libstdc++/109165 Is this supposed to be `std::size_t v2 = ch(...)`? > + > + VERIFY( v2 == v ); > +} > + > +int main() > +{ > + test01(); > +} > -- > 2.39.2 >
On Sat, 18 Mar 2023 at 00:49, Nathaniel Shead wrote: > On Sat, Mar 18, 2023 at 7:36 AM Jonathan Wakely via Libstdc++ > <libstdc++@gcc.gnu.org> wrote: > > > > Tested x86_64-linux. Pushed to trunk. gcc-12 backport needed too. > > > > -- >8 -- > > > > libstdc++-v3/ChangeLog: > > > > PR libstdc++/109165 > > * include/std/coroutine (hash<>::operator()): Add const. > > * testsuite/18_support/coroutines/hash.cc: New test. > > --- > > libstdc++-v3/include/std/coroutine | 2 +- > > .../testsuite/18_support/coroutines/hash.cc | 22 +++++++++++++++++++ > > 2 files changed, 23 insertions(+), 1 deletion(-) > > create mode 100644 libstdc++-v3/testsuite/18_support/coroutines/hash.cc > > > > diff --git a/libstdc++-v3/include/std/coroutine > b/libstdc++-v3/include/std/coroutine > > index f6e65566f10..b0ca18949db 100644 > > --- a/libstdc++-v3/include/std/coroutine > > +++ b/libstdc++-v3/include/std/coroutine > > @@ -345,7 +345,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > > struct hash<coroutine_handle<_Promise>> > > { > > size_t > > - operator()(const coroutine_handle<_Promise>& __h) noexcept > > + operator()(const coroutine_handle<_Promise>& __h) const noexcept > > { > > return reinterpret_cast<size_t>(__h.address()); > > } > > diff --git a/libstdc++-v3/testsuite/18_support/coroutines/hash.cc > b/libstdc++-v3/testsuite/18_support/coroutines/hash.cc > > new file mode 100644 > > index 00000000000..68e5e640477 > > --- /dev/null > > +++ b/libstdc++-v3/testsuite/18_support/coroutines/hash.cc > > @@ -0,0 +1,22 @@ > > +// { dg-options "-std=gnu++2a" } > > +// { dg-do run { target c++2a } } > > + > > +#include <coroutine> > > +#include <testsuite_hooks.h> > > + > > +void > > +test01() > > +{ > > + std::hash<std::noop_coroutine_handle> h; > > + std::size_t v = h(std::noop_coroutine()); > > + > > + const auto& ch = h; > > + std::size_t v2 = h(std::noop_coroutine()); // PR libstdc++/109165 > > Is this supposed to be `std::size_t v2 = ch(...)`? > > Doh! Yes, thanks. Fixed by the attached change. Tested x86_64-linux, pushed to trunk. commit 9b83d4755a7da02f25788fce14bec949e7045f8f Author: Jonathan Wakely <jwakely@redhat.com> Date: Fri Mar 17 11:39:55 2023 libstdc++: Fix test for hash<coroutine_handle<P>>::operator() [PR109165] libstdc++-v3/ChangeLog: PR libstdc++/109165 * testsuite/18_support/coroutines/hash.cc: Use const object in second call. diff --git a/libstdc++-v3/testsuite/18_support/coroutines/hash.cc b/libstdc++-v3/testsuite/18_support/coroutines/hash.cc index 68e5e640477..81b68f8246a 100644 --- a/libstdc++-v3/testsuite/18_support/coroutines/hash.cc +++ b/libstdc++-v3/testsuite/18_support/coroutines/hash.cc @@ -7,11 +7,12 @@ void test01() { + auto coro = std::noop_coroutine(); std::hash<std::noop_coroutine_handle> h; - std::size_t v = h(std::noop_coroutine()); + std::size_t v = h(coro); const auto& ch = h; - std::size_t v2 = h(std::noop_coroutine()); // PR libstdc++/109165 + std::size_t v2 = ch(coro); // PR libstdc++/109165 VERIFY( v2 == v ); }
diff --git a/libstdc++-v3/include/std/coroutine b/libstdc++-v3/include/std/coroutine index f6e65566f10..b0ca18949db 100644 --- a/libstdc++-v3/include/std/coroutine +++ b/libstdc++-v3/include/std/coroutine @@ -345,7 +345,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct hash<coroutine_handle<_Promise>> { size_t - operator()(const coroutine_handle<_Promise>& __h) noexcept + operator()(const coroutine_handle<_Promise>& __h) const noexcept { return reinterpret_cast<size_t>(__h.address()); } diff --git a/libstdc++-v3/testsuite/18_support/coroutines/hash.cc b/libstdc++-v3/testsuite/18_support/coroutines/hash.cc new file mode 100644 index 00000000000..68e5e640477 --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/coroutines/hash.cc @@ -0,0 +1,22 @@ +// { dg-options "-std=gnu++2a" } +// { dg-do run { target c++2a } } + +#include <coroutine> +#include <testsuite_hooks.h> + +void +test01() +{ + std::hash<std::noop_coroutine_handle> h; + std::size_t v = h(std::noop_coroutine()); + + const auto& ch = h; + std::size_t v2 = h(std::noop_coroutine()); // PR libstdc++/109165 + + VERIFY( v2 == v ); +} + +int main() +{ + test01(); +}