diff --git a/include/boost/move/core.hpp b/include/boost/move/core.hpp index 771c780..55486e6 100644 --- a/include/boost/move/core.hpp +++ b/include/boost/move/core.hpp @@ -53,10 +53,10 @@ #include - #if 1 - #define BOOST_MOVE_TO_RV_CAST(RV_TYPE, ARG) static_cast(ARG) - #else + #if defined(BOOST_MOVE_ADDRESS_SANITIZER_ON) #define BOOST_MOVE_TO_RV_CAST(RV_TYPE, ARG) reinterpret_cast(ARG) + #else + #define BOOST_MOVE_TO_RV_CAST(RV_TYPE, ARG) static_cast(ARG) #endif //Move emulation rv breaks standard aliasing rules so add workarounds for some compilers diff --git a/include/boost/move/detail/workaround.hpp b/include/boost/move/detail/workaround.hpp index 67ba161..b3f81b1 100644 --- a/include/boost/move/detail/workaround.hpp +++ b/include/boost/move/detail/workaround.hpp @@ -23,6 +23,16 @@ #define BOOST_MOVE_PERFECT_FORWARDING #endif +#if defined(__has_feature) + #define BOOST_MOVE_HAS_FEATURE __has_feature +#else + #define BOOST_MOVE_HAS_FEATURE(x) 0 +#endif + +#if BOOST_MOVE_HAS_FEATURE(address_sanitizer) || defined(__SANITIZE_ADDRESS__) + #define BOOST_MOVE_ADDRESS_SANITIZER_ON +#endif + //Macros for documentation purposes. For code, expands to the argument #define BOOST_MOVE_IMPDEF(TYPE) TYPE #define BOOST_MOVE_SEEDOC(TYPE) TYPE