From 1c6d460167163cbccde14c41fe94561175baefb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Thu, 19 Jun 2008 14:29:52 +0000 Subject: [PATCH] #2019: Intrusive lists seem to return invalid references with member hooks in 64 bit mode on calling front/back [SVN r46511] --- .../boost/intrusive/detail/parent_from_member.hpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/include/boost/intrusive/detail/parent_from_member.hpp b/include/boost/intrusive/detail/parent_from_member.hpp index c566e77..c3becf1 100644 --- a/include/boost/intrusive/detail/parent_from_member.hpp +++ b/include/boost/intrusive/detail/parent_from_member.hpp @@ -16,6 +16,11 @@ #include #include +#if defined(BOOST_MSVC) || (defined (BOOST_WINDOWS) && defined(BOOST_INTEL)) +#define BOOST_INTRUSIVE_OFFSET_FROM_PTR2MEMBER_MSVC_COMPLIANT +#include +#endif + namespace boost { namespace intrusive { namespace detail { @@ -23,11 +28,10 @@ namespace detail { template inline std::size_t offset_from_pointer_to_member(const Member Parent::* ptr_to_member) { - //BOOST_STATIC_ASSERT(( sizeof(std::ptrdiff_t) == sizeof(ptr_to_member) )); //The implementation of a pointer to member is compiler dependent. - #if defined(BOOST_MSVC) || (defined (BOOST_WINDOWS) && defined(BOOST_INTEL)) + #if defined(BOOST_INTRUSIVE_OFFSET_FROM_PTR2MEMBER_MSVC_COMPLIANT) //This works with gcc, msvc, ac++, ibmcpp - return *(const std::ptrdiff_t*)(void*)&ptr_to_member; + return *(const boost::int32_t*)(void*)&ptr_to_member; #elif defined(__GNUC__) || defined(__HP_aCC) || defined(BOOST_INTEL) || defined (__IBMCPP__) || defined (__DECCXX) const Parent * const parent = 0; const char *const member = reinterpret_cast(&(parent->*ptr_to_member)); @@ -56,6 +60,10 @@ inline const Parent *parent_from_member(const Member *member, const Member Paren } //namespace intrusive { } //namespace boost { +#ifdef BOOST_INTRUSIVE_OFFSET_FROM_PTR2MEMBER_MSVC_COMPLIANT +#undef BOOST_INTRUSIVE_OFFSET_FROM_PTR2MEMBER_MSVC_COMPLIANT +#endif + #include #endif //#ifndef BOOST_INTRUSIVE_PARENT_FROM_MEMBER_HPP