From ca32e1c25908866b277f5332bb308f23de54e187 Mon Sep 17 00:00:00 2001 From: "Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)" Date: Thu, 16 Sep 2021 17:08:59 +0100 Subject: Fix last two commits by using volatile to prevent dead store elimination. --- include/llfio/v2.0/detail/impl/map_handle.ipp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/include/llfio/v2.0/detail/impl/map_handle.ipp b/include/llfio/v2.0/detail/impl/map_handle.ipp index 46fc46c8..e03587a7 100644 --- a/include/llfio/v2.0/detail/impl/map_handle.ipp +++ b/include/llfio/v2.0/detail/impl/map_handle.ipp @@ -173,8 +173,24 @@ namespace detail }; extern inline QUICKCPPLIB_SYMBOL_VISIBLE map_handle_cache_t *map_handle_cache() { - static auto v = std::make_unique(); - return v.get(); + static struct _ + { + map_handle_cache_t *v; + _() + : v(new map_handle_cache_t) + { + } + ~_() + { + if(v != nullptr) + { + auto *r = v; + *(volatile map_handle_cache_t **) &v = nullptr; + delete r; + } + } + } v; + return v.v; } } // namespace detail -- cgit v1.2.3