From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30594 invoked by alias); 19 Jun 2019 12:43:26 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 30584 invoked by uid 89); 19 Jun 2019 12:43:26 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: mail-wr1-f51.google.com Received: from mail-wr1-f51.google.com (HELO mail-wr1-f51.google.com) (209.85.221.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 19 Jun 2019 12:43:24 +0000 Received: by mail-wr1-f51.google.com with SMTP id n4so3270385wrs.3 for ; Wed, 19 Jun 2019 05:43:24 -0700 (PDT) Return-Path: Received: from ?IPv6:2001:8a0:f913:f700:56ee:75ff:fe8d:232b? ([2001:8a0:f913:f700:56ee:75ff:fe8d:232b]) by smtp.gmail.com with ESMTPSA id x129sm1624031wmg.44.2019.06.19.05.43.21 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jun 2019 05:43:21 -0700 (PDT) Subject: Re: [PATCH][gdb] Fix build breaker with gcc 4.8 To: Tom de Vries , gdb-patches@sourceware.org References: <20190619110410.GA14131@delia> From: Pedro Alves Message-ID: Date: Wed, 19 Jun 2019 12:43:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20190619110410.GA14131@delia> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-SW-Source: 2019-06/txt/msg00372.txt.bz2 On 6/19/19 12:04 PM, Tom de Vries wrote: > Hi, > > When compiling with gcc 4.8, we run into: > ... > /usr/include/c++/4.8/bits/unordered_map.h:100:18: required from \ > ‘class std::unordered_map >’ > src/gdb/dwarf2read.h:260:5: required from here > /usr/include/c++/4.8/bits/hashtable_policy.h:1070:12: error: invalid use of \ > incomplete type ‘struct std::hash’ > ... > > Fix this by adding std::hash. > > Build and reg-tested on x86_64-linux with gcc 4.8. > > OK for trunk? > hash_enum was added for this: https://sourceware.org/ml/gdb-patches/2017-12/msg00210.html Can you use it here? It's currently used in dwarf2read.c, here: std::unordered_map> Thanks, Pedro Alves > Thanks, > - Tom > > [gdb] Fix build breaker with gcc 4.8 > > gdb/ChangeLog: > > 2019-06-19 Tom de Vries > > * dwarf2read.h (std::hash): New specialization. > > --- > gdb/dwarf2read.h | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/gdb/dwarf2read.h b/gdb/dwarf2read.h > index 776860e454..494dcb32c1 100644 > --- a/gdb/dwarf2read.h > +++ b/gdb/dwarf2read.h > @@ -99,6 +99,26 @@ struct signatured_type; > struct die_info; > typedef struct die_info *die_info_ptr; > > +/* An std::hash specialization, required for use of sect_offset in > + std::unordered_map with gcc 4.8. */ > + > +namespace std > +{ > + template<> struct hash > + { > + typedef sect_offset argument_type; > + typedef std::size_t result_type; > + using underlying_type > + = typename std::underlying_type::type; > + > + result_type operator() (const argument_type &o) const noexcept > + { > + underlying_type u = static_cast (o); > + return std::hash {} (u); > + } > + }; > +}; > + > /* Collection of data recorded per objfile. > This hangs off of dwarf2_objfile_data_key. */ > >