From d1d62f3adc21b502ca83011f0f6dba115efe2970 Mon Sep 17 00:00:00 2001 From: Beman Date: Fri, 7 Jun 2013 15:46:14 -0400 Subject: [PATCH] Use detail::reverse_value() to implement reverse_value() for float and double, thus eliminating type-punning warning from gcc. --- include/boost/endian/conversion.hpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/boost/endian/conversion.hpp b/include/boost/endian/conversion.hpp index 6353ea4..1c62db9 100644 --- a/include/boost/endian/conversion.hpp +++ b/include/boost/endian/conversion.hpp @@ -236,16 +236,14 @@ namespace endian { BOOST_STATIC_ASSERT_MSG(sizeof(float) == sizeof(uint32_t), "boost::endian only supprts sizeof(float) == 4; please report error to boost mailing list"); - uint32_t tmp = reverse_value(*(const uint32_t*)&x); - return *(const float*)&tmp; + return detail::reverse_value(x); } inline double reverse_value(double x) BOOST_NOEXCEPT { BOOST_STATIC_ASSERT_MSG(sizeof(double) == sizeof(uint64_t), "boost::endian only supprts sizeof(double) == 8; please report error to boost mailing list"); - uint64_t tmp = reverse_value(*(const uint64_t*)&x); - return *(const double*)&tmp; + return detail::reverse_value(x); } namespace detail