From patchwork Tue Nov 14 22:32:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 165129 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:a59:b0:164:83eb:24d7 with SMTP id 25csp2271812rwb; Tue, 14 Nov 2023 15:37:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEXeDPSXPHVBSu50lGNMWJydiF7oS9/BoqGhJwFbllV77YW/Cb5yCXHO5eGRlsc8AYPeWnR X-Received: by 2002:a05:620a:2a16:b0:77b:d5d4:a105 with SMTP id o22-20020a05620a2a1600b0077bd5d4a105mr4431460qkp.38.1700005069266; Tue, 14 Nov 2023 15:37:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700005069; cv=pass; d=google.com; s=arc-20160816; b=K88lEs/lwBwcZTKVcvQ2ou9UKOpxgYLkJ+hjCw9ieawFG+TKFxPbYn2TUjFezRBa4H QO3WSe53TEZicVXs8ZGwMik5zyacjxDCy1UaZ0i5tNWO4UpW/kpazg48UrTt2ZDY5E9F hPd4SAvn6cFFHrE9ZAC/W0+WnJyE4q8UO0MCOyHC79Q5jHJ9wbVsv12qkmzQqJvF+8pN XiO+J760MWykuwtR117bGALg4MuwAHPlvm8wMqD2zBL+P2BmvUKM/OHsS2Bv91FevtMF liw1oUbCP2hgAQnEYnCY9l/b3FTX5P47x/TortEbt6vqQYtO/mxvkD2zI7BjX+Q1amna oDjg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=TFI/xsSYKpiDcMgi0951kFbai3BVMvCgVoPykn6YPOw=; fh=sJ+2/4g29YdyXkoRrFZSpsL2zxijepB7X/1rB0LDDh8=; b=A9PDbrKo4iNW+a1ZdNALnqTDpGUUqj/nzsro1H0dualihC+q7MRBRLd8hMPs/SDmos UAknph52G9gCGNdIJdwMJpEPWMQhe47R49cnb41ABoCFpn8O5tQG6dbx+mu0JtInL9TF dtAMw6Z4ULBqa/W3m9GXRSowNu6T/O/ZdmekGWuBWOwibrVYCL0uGk2dFJ+dtO46X3fY D1GK4lsmp3VxgUhM7VWxI+yLtHMsdkfuEIew9rP2IVTuRQcNxT2aP7BahQKjbN+99GNV co+F4Luocm3ZO9J8i3CGG5r+ao7zGWjEwEhMSIqbANm2l0NzM9z2byamKOY4vEjWe5f7 3NoA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eULFMTHc; arc=pass (i=1); 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=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id a18-20020a05620a103200b0077bcbb62af2si7576467qkk.650.2023.11.14.15.37.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 15:37:49 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=eULFMTHc; arc=pass (i=1); 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=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E2C083857C47 for ; Tue, 14 Nov 2023 22:33:20 +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 816D23858D35 for ; Tue, 14 Nov 2023 22:32:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 816D23858D35 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 816D23858D35 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=1700001175; cv=none; b=LX5K04eMsMo6Co/Wglictky6P0aJ2MuykjQDMGZ3AO2TPlAh7yuMkf35ls6GkGh9Yed2Ulup0QnSZS5jmwFyLW/IDfmGleN6RByprsk7pNLwcgZzjHPwwIapsKYG/i3FxAbitTBN2jco7h26d6+GE79jYU0Pe+tahb12NuDH164= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700001175; c=relaxed/simple; bh=pAu6Fej6jjiK4/jvl1X1qYjBMc7pzmJPwzCAx69oOus=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Tzg5so/Tkq5lHLI1Z6oA3uE+29XPwY7AeHbn7vLF7ad++E8N+6Q06YAUqSoS00sun03NJGSUOVkwdcsfzER2rqIejilOYOFMr8qSCaXOr+WuhBZPpWJDLi4CbjDla9FbC9+KkMjTffg5zJBVwj2dRPOk17PcD4Ing2sr6wMQiM8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700001174; 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=TFI/xsSYKpiDcMgi0951kFbai3BVMvCgVoPykn6YPOw=; b=eULFMTHceDqMsM3vfys4g6uceovyq+qFMpHalhXTwO4bBRDkovkcuyH3W75uAIbMCv//+N FINOiVdQpJJ0dV6Pcst/qI2KwA7WdbED/eYugD2SGef7w+JV/uKf6ZjupMNkkp4Lo/tLnc f2Yaspa2Pi0aigzh+73PT3mXP7lBxM8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-645-axD8CHf0N8OpiaB-q4LR6Q-1; Tue, 14 Nov 2023 17:32:52 -0500 X-MC-Unique: axD8CHf0N8OpiaB-q4LR6Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 8DE0B84B108; Tue, 14 Nov 2023 22:32:52 +0000 (UTC) Received: from localhost (unknown [10.42.28.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5877C1121306; Tue, 14 Nov 2023 22:32:52 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Fix std::hash [PR112348] Date: Tue, 14 Nov 2023 22:32:21 +0000 Message-ID: <20231114223251.951537-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.8 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=ham 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782584515348561768 X-GMAIL-MSGID: 1782584515348561768 Tested x86_64-linux. Pushed to trunk. Backports needed too. -- >8 -- libstdc++-v3/ChangeLog: PR libstdc++/112348 * include/std/stacktrace (hash>): Fix type of hash functio nfor entries. * testsuite/19_diagnostics/stacktrace/hash.cc: New test. --- libstdc++-v3/include/std/stacktrace | 2 +- .../19_diagnostics/stacktrace/hash.cc | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 libstdc++-v3/testsuite/19_diagnostics/stacktrace/hash.cc diff --git a/libstdc++-v3/include/std/stacktrace b/libstdc++-v3/include/std/stacktrace index da0e48d3532..9a0d0b16068 100644 --- a/libstdc++-v3/include/std/stacktrace +++ b/libstdc++-v3/include/std/stacktrace @@ -797,7 +797,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION size_t operator()(const basic_stacktrace<_Allocator>& __st) const noexcept { - hash __h; + hash __h; size_t __val = _Hash_impl::hash(__st.size()); for (const auto& __f : __st) __val = _Hash_impl::__hash_combine(__h(__f), __val); diff --git a/libstdc++-v3/testsuite/19_diagnostics/stacktrace/hash.cc b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/hash.cc new file mode 100644 index 00000000000..88831efd687 --- /dev/null +++ b/libstdc++-v3/testsuite/19_diagnostics/stacktrace/hash.cc @@ -0,0 +1,23 @@ +// { dg-options "-lstdc++exp" } +// { dg-do run { target c++23 } } +// { dg-require-effective-target stacktrace } + +#include +#include +#include + +void +test_hash() +{ + using Alloc = __gnu_test::uneq_allocator; + using S = std::basic_stacktrace; + S s; + std::size_t h = std::hash()(s); + std::size_t h2 = std::hash()(S::current()); + VERIFY( h != h2 ); +} + +int main() +{ + test_hash(); +}