From 12763abc53bb8c4d9953992b003f4a59a59473ce Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 14 Nov 2018 17:43:38 +0100 Subject: [PATCH] re PR bootstrap/86739 (Bootstrap broken with host GCC 4.1.2) PR bootstrap/86739 * hash-map.h (hash_map::iterator::reference_pair): New class. (hash_map::iterator::operator*): Return it rather than std::pair. From-SVN: r266152 --- gcc/ChangeLog | 6 ++++++ gcc/hash-map.h | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index be75c6874c8..ae27a137d15 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-11-14 Jakub Jelinek + + PR bootstrap/86739 + * hash-map.h (hash_map::iterator::reference_pair): New class. + (hash_map::iterator::operator*): Return it rather than std::pair. + 2018-11-14 Jeff Law * optabs.c (expand_binop): Pass INT_MODE to operand_subword_force diff --git a/gcc/hash-map.h b/gcc/hash-map.h index 39848289d80..5cee4a400d8 100644 --- a/gcc/hash-map.h +++ b/gcc/hash-map.h @@ -223,10 +223,23 @@ public: return *this; } - std::pair operator* () + /* Can't use std::pair here, because GCC before 4.3 don't handle + std::pair where template parameters are references well. + See PR86739. */ + struct reference_pair { + const Key &first; + Value &second; + + reference_pair (const Key &key, Value &value) : first (key), second (value) {} + + template + operator std::pair () const { return std::pair (first, second); } + }; + + reference_pair operator* () { hash_entry &e = *m_iter; - return std::pair (e.m_key, e.m_value); + return reference_pair (e.m_key, e.m_value); } bool -- 2.30.2