mirror of
https://github.com/boostorg/filesystem.git
synced 2025-05-12 13:41:47 +00:00
Use volatile to make sure globals_retainer is not optimized away.
By using volatile qualifier for the internal member of the globals_retainer class we ensure the constructor formally has observable behavior, which means it cannot be optimized away. Related to https://github.com/boostorg/filesystem/issues/217.
This commit is contained in:
parent
fa53749ac7
commit
04c6e582be
@ -1568,9 +1568,9 @@ extern const init_func_ptr_t p_init_path_globals = &init_path_globals;
|
||||
//! Makes sure the global initializer pointers are referenced and not removed by linker
|
||||
struct globals_retainer
|
||||
{
|
||||
const init_func_ptr_t* const m_p_init_path_globals;
|
||||
const init_func_ptr_t* volatile m_p_init_path_globals;
|
||||
|
||||
globals_retainer() : m_p_init_path_globals(&p_init_path_globals) {}
|
||||
globals_retainer() { m_p_init_path_globals = &p_init_path_globals; }
|
||||
};
|
||||
BOOST_ATTRIBUTE_UNUSED
|
||||
static const globals_retainer g_globals_retainer
|
||||
|
Loading…
x
Reference in New Issue
Block a user