[Boost-bugs] [Boost C++ Libraries] #12806: flat_map.hpp function force_copy break strict-aliasing on gcc < 4.4

Subject: [Boost-bugs] [Boost C++ Libraries] #12806: flat_map.hpp function force_copy break strict-aliasing on gcc < 4.4
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-02-02 16:38:59


#12806: flat_map.hpp function force_copy break strict-aliasing on gcc < 4.4
----------------------------------+-------------------------
 Reporter: Vladislav <phprus@…> | Owner: igaztanaga
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: container
  Version: Boost 1.63.0 | Severity: Showstopper
 Keywords: |
----------------------------------+-------------------------
 Hello!

 On function
 ([https://github.com/boostorg/container/blob/develop/include/boost/container/flat_map.hpp#L61]):

 {{{
 template<class D, class S>
 BOOST_CONTAINER_FORCEINLINE static D force_copy(S s)
 {
    D *vp = reinterpret_cast<D *>(&s);
    return D(*vp);
 }
 }}}

 gcc 4.3.4 (SLE 11) produced wrong code.
 It seems that the compiler does not create a copy of an object "s" and
 returns an object of D().

 If I change the signature of function on "BOOST_CONTAINER_FORCEINLINE
 static D force_copy(const S& s)" the code works and the tests pass. But
 then does not create a copy of an object "s" in a function call.

 I'm not sure that this change is correct.
 Is there any other workaround for this problem with a compiler gcc 4.3 or
 better disable strict-aliasing?

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12806>
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-02-16 18:50:21 UTC