From 823d20044c74ff8524954b2f3b01a51f390567b0 Mon Sep 17 00:00:00 2001 From: Jose Dapena Paz Date: Tue, 29 May 2018 18:38:39 +0000 Subject: [PATCH] GCC: workaround GCC bug "std::map::insert(value_type &&) not selected" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are several calls following this pattern: std:map> map; A a; std::unique_ptr b; map.insert({a, std::move(b)}); This fails in gcc < 7.3 because the operator for inserting from && is not present, as reported here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82522 So apply a workaround that makes the move steps explicit. Change-Id: I54cea26eac6e74a3d9c2d17a37e3c4c9ce62fd74 Reviewed-on: https://chromium-review.googlesource.com/1076471 Reviewed-by: Dave Tapuska Reviewed-by: Dan Elphick Commit-Queue: José Dapena Paz Cr-Commit-Position: refs/heads/master@{#562519} --- content/browser/background_fetch/background_fetch_context.cc | 5 ++++- content/renderer/input/input_event_prediction.cc | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/content/browser/background_fetch/background_fetch_context.cc b/content/browser/background_fetch/background_fetch_context.cc index 5dec01f82db31..649d4595ba83e 100644 --- ./content/browser/background_fetch/background_fetch_context.cc +++ ./content/browser/background_fetch/background_fetch_context.cc @@ -222,7 +222,10 @@ void BackgroundFetchContext::InitializeController( scheduler_->AddJobController(controller.get()); - job_controllers_.insert({unique_id, std::move(controller)}); + // Workaround for GLIBC C++ < 7.3 that fails to insert with braces + // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82522 + auto pair = std::make_pair(unique_id, std::move(controller)); + job_controllers_.insert(std::move(pair)); std::move(done_closure).Run(); } diff --git a/content/renderer/input/input_event_prediction.cc b/content/renderer/input/input_event_prediction.cc index 89636c9736da5..f1bce36364ed9 100644 --- ./content/renderer/input/input_event_prediction.cc +++ ./content/renderer/input/input_event_prediction.cc @@ -119,7 +119,10 @@ void InputEventPrediction::UpdateSinglePointer( if (predictor != pointer_id_predictor_map_.end()) { predictor->second->Update(data); } else { - pointer_id_predictor_map_.insert({event.id, SetUpPredictor()}); + // Workaround for GLIBC C++ < 7.3 that fails to insert with braces + // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82522 + auto pair = std::make_pair(event.id, SetUpPredictor()); + pointer_id_predictor_map_.insert(std::move(pair)); pointer_id_predictor_map_[event.id]->Update(data); } }