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 B8ACB385085C for ; Fri, 17 Mar 2023 20:36:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B8ACB385085C 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=1679085366; 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=Nl6hZFwJsayJutTA5abDLe8p3jJ5G4IFDrnoMQlG0Ks=; b=Hf9K82l709gGRDdTEJWg+uPQtVg2ASU7lgM18cNI8i3ADNlPxDCZOEBR1aCt16jnH8uRTL WCLcmCPh1BbFt65CBPwErfYO6V9LAVVI7pxQYx4kEG6wV5hl3oRK42VFAinYD2hkhiKw7z DEFEjQY2fIebU1lMULX7vZalWRa2WU0= 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) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Add const to hash>::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 List-Id: 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> { size_t - operator()(const coroutine_handle<_Promise>& __h) noexcept + operator()(const coroutine_handle<_Promise>& __h) const noexcept { return reinterpret_cast(__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 +#include + +void +test01() +{ + std::hash 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(); +} -- 2.39.2