Skip to content

Commit

Permalink
Fix last two commits by using volatile to prevent dead store eliminat…
Browse files Browse the repository at this point in the history
…ion.
  • Loading branch information
ned14 committed Sep 16, 2021
1 parent ac83bef commit ca32e1c
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions include/llfio/v2.0/detail/impl/map_handle.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,24 @@ namespace detail
};
extern inline QUICKCPPLIB_SYMBOL_VISIBLE map_handle_cache_t *map_handle_cache()
{
static auto v = std::make_unique<map_handle_cache_t>();
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

Expand Down

0 comments on commit ca32e1c

Please sign in to comment.