From 1fd0cd5510596145e20525dee15208b44a0f5c15 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Fri, 22 May 2020 11:25:38 -0700 Subject: [PATCH] Avoid forming owning_lock of incomplete type in history Older libstdc++ will error on this. Partially addresses #7023 --- src/history.cpp | 14 ++++++++++---- src/history.h | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/history.cpp b/src/history.cpp index 4a316c35a..8a8f070cc 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -1231,20 +1231,26 @@ static bool string_could_be_path(const wcstring &potential_path) { return !(potential_path.empty() || potential_path.at(0) == L'-'); } +/// impl_wrapper_t is used to avoid forming owning_lock in +/// the .h file; see #7023. +struct history_t::impl_wrapper_t { + owning_lock impl; + explicit impl_wrapper_t(wcstring &&name) : impl(history_impl_t(std::move(name))) {} +}; + /// Very simple, just mark that we have no more pending items. void history_impl_t::resolve_pending() { this->has_pending_item = false; } bool history_t::chaos_mode = false; bool history_t::never_mmap = false; -history_t::history_t(wcstring name) - : impl_(make_unique>(history_impl_t(std::move(name)))) {} +history_t::history_t(wcstring name) : wrap_(make_unique(std::move(name))) {} history_t::~history_t() = default; -acquired_lock history_t::impl() { return impl_->acquire(); } +acquired_lock history_t::impl() { return wrap_->impl.acquire(); } -acquired_lock history_t::impl() const { return impl_->acquire(); } +acquired_lock history_t::impl() const { return wrap_->impl.acquire(); } bool history_t::is_default() const { return impl()->is_default(); } diff --git a/src/history.h b/src/history.h index 1c1e746b5..5f9f16693 100644 --- a/src/history.h +++ b/src/history.h @@ -114,7 +114,8 @@ struct history_impl_t; class history_t { friend class history_tests_t; - const std::unique_ptr> impl_; + struct impl_wrapper_t; + const std::unique_ptr wrap_; // No copying or moving. history_t() = delete;