Hello, I think that after this patch is when I am seeing these errors when building cross toolchains, for arm-none-eabi and aarch64-none-elf, using gcc 4.8. The errors are: In file included from /…/src/binutils-gdb--gdb/gdbsupport/common-defs.h:206:0, from /…/src/binutils-gdb--gdb/gdbsupport/common-exceptions.cc:20: /…/src/binutils-gdb--gdb/gdbsupport/ptid.h:161:13: error: specialization of ‘template struct std::hash’ in different namespace [-fpermissive] struct std::hash ^ Kind regards, Vasee ________________________________ From: Gdb-patches on behalf of Simon Marchi via Gdb-patches Sent: 11 September 2023 18:14 To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Specialize std::hash for ptid_t On 9/11/23 12:35, Tom Tromey wrote: >>>>>> "Simon" == Simon Marchi writes: > > Simon> When searching on that topic, I found some sources advising against > Simon> opening namespace std, like this one: > ... > > Sounds good, here's v2. > > Tom > > commit 1d5a09c85bf97846438246397aaf4aae360c3783 > Author: Tom Tromey > Date: Mon Sep 11 08:45:37 2023 -0600 > > Specialize std::hash for ptid_t > > This changes hash_ptid to instead be a specialization of std::hash. > This makes it a little easier to use with standard containers. > > diff --git a/gdb/inferior.h b/gdb/inferior.h > index 04672582984..29c90d15efa 100644 > --- a/gdb/inferior.h > +++ b/gdb/inferior.h > @@ -462,7 +462,7 @@ class inferior : public refcounted_object, > > /* A map of ptid_t to thread_info*, for average O(1) ptid_t lookup. > Exited threads do not appear in the map. */ > - std::unordered_map ptid_thread_map; > + std::unordered_map ptid_thread_map; > > /* Returns a range adapter covering the inferior's threads, > including exited threads. Used like this: > diff --git a/gdb/regcache.c b/gdb/regcache.c > index 9b71931bb0b..91b20b7a2a2 100644 > --- a/gdb/regcache.c > +++ b/gdb/regcache.c > @@ -329,7 +329,7 @@ reg_buffer::assert_regnum (int regnum) const > regcaches, associated to different gdbarches). */ > > using ptid_regcache_map > - = std::unordered_multimap; > + = std::unordered_multimap; > > /* Type holding regcaches for a given pid. */ > > diff --git a/gdbsupport/ptid.h b/gdbsupport/ptid.h > index aa296b83181..f8644d47633 100644 > --- a/gdbsupport/ptid.h > +++ b/gdbsupport/ptid.h > @@ -157,9 +157,8 @@ class ptid_t > tid_type m_tid; > }; > > -/* Functor to hash a ptid. */ > - > -struct hash_ptid > +template<> > +struct std::hash > { > size_t operator() (const ptid_t &ptid) const > { LGTM, thanks. Approved-By: Simon Marchi Simon