[Boost-bugs] [Boost C++ Libraries] #12940: Missing initializer for member

Subject: [Boost-bugs] [Boost C++ Libraries] #12940: Missing initializer for member
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-03-30 09:56:42


#12940: Missing initializer for member
------------------------------+--------------------------
 Reporter: mattyclarkson@… | Owner: timblechmann
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: atomic
  Version: Boost 1.63.0 | Severity: Problem
 Keywords: |
------------------------------+--------------------------
 I have the following error when compiling with my built boost 1.63:

 {{{
 /usr/include/boost/atomic/detail/bitwise_cast.hpp: In instantiation of 'To
 boost::atomics::detail::bitwise_cast(const From&) [with To = long unsigned
 int; From = void*]':
 /usr/include/boost/atomic/detail/atomic_template.hpp:556:139: required
 from here
 /usr/include/boost/atomic/detail/bitwise_cast.hpp:39:14: error: missing
 initializer for member 'boost::atomics::detail::bitwise_cast(const From&)
 [with To = long unsigned int; From = void*]::<anonymous struct>::to'
 [-Werror=missing-field-initializers]
      value = {};

 }}}


 The code looks like:


 {{{
 template< typename To, typename From >
 BOOST_FORCEINLINE To bitwise_cast(From const& from) BOOST_NOEXCEPT
 {
     struct
     {
         To to;
     }
     value = {};
     BOOST_ATOMIC_DETAIL_MEMCPY
     (
         &reinterpret_cast< char& >(value.to),
         &reinterpret_cast< const char& >(from),
         (sizeof(From) < sizeof(To) ? sizeof(From) : sizeof(To))
     );
     return value.to;
 }
 }}}

 My proposed fix is:


 {{{
 template< typename To, typename From >
 BOOST_FORCEINLINE To bitwise_cast(From const& from) BOOST_NOEXCEPT
 {
     struct Value
     {
         To to;
         Value() : to() {}
     }
     struct Value value;
     BOOST_ATOMIC_DETAIL_MEMCPY
     (
         &reinterpret_cast< char& >(value.to),
         &reinterpret_cast< const char& >(from),
         (sizeof(From) < sizeof(To) ? sizeof(From) : sizeof(To))
     );
     return value.to;
 }
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12940>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-03-30 10:02:49 UTC