diff --git a/src/core/mpi/RecvBuffer.h b/src/core/mpi/RecvBuffer.h index cf8e327437fad21157cee9d7441e8c196fa1f23e..5015f9bf52c8373cf70c0eb72286027cd5498971 100644 --- a/src/core/mpi/RecvBuffer.h +++ b/src/core/mpi/RecvBuffer.h @@ -38,7 +38,7 @@ #include <boost/utility/enable_if.hpp> #include <algorithm> - +#include <cstring> namespace walberla { namespace mpi { @@ -389,7 +389,6 @@ inline bool GenericRecvBuffer<T>::isEmpty() const */ template< typename T > // Element type template< typename V > // Type of the built-in data value -ATTRIBUTE_NO_SANITIZE_UNDEFINED typename boost::enable_if< boost::mpl::or_< boost::is_arithmetic<V>, boost::is_enum<V> >, GenericRecvBuffer<T> & >::type GenericRecvBuffer<T>::get( V& value ) @@ -408,9 +407,8 @@ GenericRecvBuffer<T>::get( V& value ) WALBERLA_ASSERT_LESS_EQUAL( cur_ + (sizeof(V) / sizeof(T)), end_ ); // Extracting the data value - V* tmp = reinterpret_cast<V*>( cur_ ); - value = *tmp; - cur_ = reinterpret_cast<T*>( ++tmp ); + std::memcpy( &value, cur_, sizeof(V) ); + cur_ += sizeof(V) / sizeof(T); // Invariants check WALBERLA_ASSERT_LESS_EQUAL( cur_, end_); diff --git a/src/core/mpi/SendBuffer.h b/src/core/mpi/SendBuffer.h index 448c94af1809115b79fa4fc91896879c2bba83c1..2b1e11c17409a630b4723483b3dd486f23a4302a 100644 --- a/src/core/mpi/SendBuffer.h +++ b/src/core/mpi/SendBuffer.h @@ -42,7 +42,7 @@ #include <algorithm> #include <typeinfo> - +#include <cstring> namespace walberla { namespace mpi { @@ -443,7 +443,6 @@ inline bool GenericSendBuffer<T,G>::isEmpty() const template< typename T // Element type , typename G > // Growth policy template< typename V > // Type of the built-in data value -ATTRIBUTE_NO_SANITIZE_UNDEFINED typename boost::enable_if< boost::mpl::or_< boost::is_arithmetic<V>, boost::is_enum<V> >, GenericSendBuffer<T,G>& >::type GenericSendBuffer<T,G>::put( V value ) @@ -464,8 +463,7 @@ GenericSendBuffer<T,G>::put( V value ) } // Adding the data value - V* const tmp( reinterpret_cast<V*>( cur_ ) ); - *tmp = value; + std::memcpy( cur_, &value, sizeof(V) ); cur_ += count; // Invariants check