From 008795c556cce1ea804cb7f1593494f2e57e3ef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sun, 11 Aug 2024 20:59:03 +0200 Subject: [PATCH] Use launder to make sure compilers assume that a parent type exists and it's alive --- include/boost/intrusive/detail/parent_from_member.hpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/include/boost/intrusive/detail/parent_from_member.hpp b/include/boost/intrusive/detail/parent_from_member.hpp index 8f1156e3..b276348d 100644 --- a/include/boost/intrusive/detail/parent_from_member.hpp +++ b/include/boost/intrusive/detail/parent_from_member.hpp @@ -22,6 +22,7 @@ #include #include +#include #include #if defined(_MSC_VER) @@ -90,15 +91,15 @@ BOOST_INTRUSIVE_FORCEINLINE std::ptrdiff_t offset_from_pointer_to_member(const M template BOOST_INTRUSIVE_FORCEINLINE Parent *parent_from_member(Member *member, const Member Parent::* ptr_to_member) { - return reinterpret_cast - (reinterpret_cast(member) - static_cast(offset_from_pointer_to_member(ptr_to_member))); + return boost::move_detail::launder(reinterpret_cast + (reinterpret_cast(member) - static_cast(offset_from_pointer_to_member(ptr_to_member)))); } template BOOST_INTRUSIVE_FORCEINLINE const Parent *parent_from_member(const Member *member, const Member Parent::* ptr_to_member) { - return reinterpret_cast - ( reinterpret_cast(member) - static_cast(offset_from_pointer_to_member(ptr_to_member)) ); + return boost::move_detail::launder(reinterpret_cast + ( reinterpret_cast(member) - static_cast(offset_from_pointer_to_member(ptr_to_member)) )); } } //namespace detail {