From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1936) id 03B65385626E; Mon, 23 May 2022 18:05:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 03B65385626E Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: John Baldwin To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Tweak the std::hash<> specialization for aarch64_features. X-Act-Checkin: binutils-gdb X-Git-Author: John Baldwin X-Git-Refname: refs/heads/master X-Git-Oldrev: d9b6e047f60ce2129eff28ad1c6690949293366b X-Git-Newrev: e8123c847f61c7458200b349615c47e9df17a0ed Message-Id: <20220523180520.03B65385626E@sourceware.org> Date: Mon, 23 May 2022 18:05:19 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 May 2022 18:05:20 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3De8123c847f61= c7458200b349615c47e9df17a0ed commit e8123c847f61c7458200b349615c47e9df17a0ed Author: John Baldwin Date: Mon May 23 11:02:55 2022 -0700 Tweak the std::hash<> specialization for aarch64_features. =20 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 previo= us version with the following error: =20 gdb/arch/aarch64.h:48:13: error: specialization of 'template= struct std::hash' in different namespace [-fpermissive] =20 struct std::hash Diff: --- gdb/arch/aarch64.h | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 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=3D=3D(const aarch64_features &lhs,= const aarch64_features &rhs) && lhs.tls =3D=3D rhs.tls; } =20 -template<> -struct std::hash +namespace std { - std::size_t operator()(const aarch64_features &features) const noexcept + template<> + struct hash { - std::size_t h; - - h =3D features.vq; - h =3D h << 1 | features.pauth; - h =3D h << 1 | features.mte; - h =3D h << 1 | features.tls; - return h; - } -}; + std::size_t operator()(const aarch64_features &features) const noexcept + { + std::size_t h; + + h =3D features.vq; + h =3D h << 1 | features.pauth; + h =3D h << 1 | features.mte; + h =3D h << 1 | features.tls; + return h; + } + }; +} =20 /* Create the aarch64 target description. */