Boost C++ Libraries: Ticket #9550: gcc warn will break strict-aliasing rule in win_iocp_handle_service.ipp:49 https://svn.boost.org/trac10/ticket/9550 <pre class="wiki">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&amp;)': 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&lt;DWORD_PTR*&gt;(&amp;hEvent) |= 1; </pre><p> I think that this problem can resolve by via lvalue char* type. </p> <pre class="wiki">char* comply_strict_aliasing_rule = reinterpret_cast&lt;char*&gt;(&amp;hEvent); *reinterpret_cast&lt;DWORD_PTR*&gt;(comply_strict_aliasing_rule) |= 1; </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9550 Trac 1.4.3 Steven Watanabe Fri, 04 Apr 2014 02:32:12 GMT <link>https://svn.boost.org/trac10/ticket/9550#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9550#comment:1</guid> <description> <p> Adding an intermediate cast doesn't make the code any more correct, although it may eliminate the warning. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>chris_kohlhoff</dc:creator> <pubDate>Mon, 05 May 2014 06:41:44 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/9550#comment:2 https://svn.boost.org/trac10/ticket/9550#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Fixed on 'develop' in <a class="ext-link" href="https://github.com/boostorg/asio/commit/e4e914bc4dd9c003987b1ca176b393b457a436c9"><span class="icon">​</span>e4e914bc4dd9c003987b1ca176b393b457a436c9</a>. </p> <p> Merged to 'master' in <a class="ext-link" href="https://github.com/boostorg/asio/commit/4e1e7d731fcc5c0104567856de476f7ce8806d72"><span class="icon">​</span>4e1e7d731fcc5c0104567856de476f7ce8806d72</a>. </p> Ticket