[Boost-bugs] [Boost C++ Libraries] #9550: gcc warn will break strict-aliasing rule in win_iocp_handle_service.ipp:49

Subject: [Boost-bugs] [Boost C++ Libraries] #9550: gcc warn will break strict-aliasing rule in win_iocp_handle_service.ipp:49
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-01-07 17:48:17


#9550: gcc warn will break strict-aliasing rule in win_iocp_handle_service.ipp:49
------------------------------+----------------------------
 Reporter: anonymous | Owner: chris_kohlhoff
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: asio
  Version: Boost 1.55.0 | Severity: Problem
 Keywords: |
------------------------------+----------------------------
 {{{
 In file included from
 C:/boost_1_55_0/boost/asio/detail/win_iocp_handle_service.hpp:319:0,
                  from
 C:/boost_1_55_0/boost/asio/detail/win_iocp_serial_port_service.hpp:26,
                  from
 C:/boost_1_55_0/boost/asio/serial_port_service.hpp:27,
                  from C:/boost_1_55_0/boost/asio/basic_serial_port.hpp:30,
                  from C:/boost_1_55_0/boost/asio/serial_port.hpp:24,
 C:/boost_1_55_0/boost/asio/detail/impl/win_iocp_handle_service.ipp: In
 constructor
 'boost::asio::detail::win_iocp_handle_service::overlapped_wrapper::overlapped_wrapper(boost::system::error_code&)':
 C:/boost_1_55_0/boost/asio/detail/impl/win_iocp_handle_service.ipp:49:44:
 warning:
 dereferencing type-punned pointer will break strict-aliasing rules
 [-Wstrict-aliasing]
        *reinterpret_cast<DWORD_PTR*>(&hEvent) |= 1;
 }}}

 I think that this problem can resolve by via lvalue char* type.
 {{{
 char* comply_strict_aliasing_rule = reinterpret_cast<char*>(&hEvent);
 *reinterpret_cast<DWORD_PTR*>(comply_strict_aliasing_rule) |= 1;
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/9550>
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:15 UTC