From: John Baldwin <jhb@FreeBSD.org>
To: gdb-patches@sourceware.org
Subject: [PUSHED] Tweak the std::hash<> specialization for aarch64_features.
Date: Mon, 23 May 2022 11:17:11 -0700 [thread overview]
Message-ID: <20220523181711.54779-1-jhb@FreeBSD.org> (raw)
Move the specialization into an explicit std namespace to workaround a
bug in older compilers. GCC 6.4.1 at least fails to compile the previous
version with the following error:
gdb/arch/aarch64.h:48:13: error: specialization of 'template<class _Tp> struct std::hash' in different namespace [-fpermissive]
struct std::hash<aarch64_features>
---
gdb/arch/aarch64.h | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/gdb/arch/aarch64.h b/gdb/arch/aarch64.h
index 72ec4193eba..8e3fd36726a 100644
--- a/gdb/arch/aarch64.h
+++ b/gdb/arch/aarch64.h
@@ -44,20 +44,23 @@ inline bool operator==(const aarch64_features &lhs, const aarch64_features &rhs)
&& lhs.tls == rhs.tls;
}
-template<>
-struct std::hash<aarch64_features>
+namespace std
{
- std::size_t operator()(const aarch64_features &features) const noexcept
+ template<>
+ struct hash<aarch64_features>
{
- std::size_t h;
+ std::size_t operator()(const aarch64_features &features) const noexcept
+ {
+ std::size_t h;
- h = features.vq;
- h = h << 1 | features.pauth;
- h = h << 1 | features.mte;
- h = h << 1 | features.tls;
- return h;
- }
-};
+ h = features.vq;
+ h = h << 1 | features.pauth;
+ h = h << 1 | features.mte;
+ h = h << 1 | features.tls;
+ return h;
+ }
+ };
+}
/* Create the aarch64 target description. */
--
2.36.1
reply other threads:[~2022-05-23 18:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220523181711.54779-1-jhb@FreeBSD.org \
--to=jhb@freebsd.org \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).