Use reinterpret_cast instead of static_cast when the address sanitizer is on to avoid errors in C++03 emulation.

This commit is contained in:
Ion Gaztañaga
2015-07-02 14:55:51 +02:00
parent 5dd4040723
commit 0a429e5de9
2 changed files with 13 additions and 3 deletions

View File

@@ -53,10 +53,10 @@
#include <boost/move/detail/type_traits.hpp>
#if 1
#define BOOST_MOVE_TO_RV_CAST(RV_TYPE, ARG) static_cast<RV_TYPE>(ARG)
#else
#if defined(BOOST_MOVE_ADDRESS_SANITIZER_ON)
#define BOOST_MOVE_TO_RV_CAST(RV_TYPE, ARG) reinterpret_cast<RV_TYPE>(ARG)
#else
#define BOOST_MOVE_TO_RV_CAST(RV_TYPE, ARG) static_cast<RV_TYPE>(ARG)
#endif
//Move emulation rv breaks standard aliasing rules so add workarounds for some compilers

View File

@@ -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