[Boost-bugs] [Boost C++ Libraries] #4538: Warning: dereferencing type-punned pointer will break strict-aliasing rules

Subject: [Boost-bugs] [Boost C++ Libraries] #4538: Warning: dereferencing type-punned pointer will break strict-aliasing rules
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-08-13 08:36:23


#4538: Warning: dereferencing type-punned pointer will break strict-aliasing rules
--------------------------------------------+-------------------------------
 Reporter: Roland Bock <rbock@…> | Owner: dgregor
     Type: Bugs | Status: new
Milestone: Boost 1.44.0 | Component: function
  Version: Boost 1.44.0 | Severity: Problem
 Keywords: |
--------------------------------------------+-------------------------------
 Hi,

 compiling the attached example with gcc-4.4.3 (Ubuntu 10.4, 64bit) with

 -Wall -O3

 leads to a long warning message (second attachment), culminating in


 {{{
 boost/1.44/include/boost/function/function_base.hpp:321: warning:
 dereferencing type-punned pointer will break strict-aliasing rules
 boost/1.44/include/boost/function/function_base.hpp:325: warning:
 dereferencing type-punned pointer will break strict-aliasing rules
 }}}


 A way to avoid this warning is been suggested by Justin in the boost-users
 mailing list:

 http://lists.boost.org/boost-users/2010/08/61564.php

 Replace:

 {{{
 reinterpret_cast<functor_type*>(&in_buffer.data)->~Functor();
 }}}

 with:

 {{{
 functor_type* p = reinterpret_cast<functor_type*>(&in_buffer.data);
 p->~Functor();
 }}}

 (Second line with out_buffer, respectively)

 As noted by Emil Dotchevski in the thread on boost-users, it seems
 questionable why splitting up the original lines can get rid of the
 warning. So maybe a ticket should be filed for gcc by someone more
 knowledgeable than me.

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