Boost logo

Boost Users :

Subject: Re: [Boost-users] [Spirit] dereferencing type-punned pointer will break strict-aliasing rules
From: Emil Dotchevski (emil_at_[hidden])
Date: 2010-08-12 14:16:43


On Thu, Aug 12, 2010 at 12:48 AM, Roland Bock <rbock_at_[hidden]> wrote:
> On 08/12/2010 08:26 AM, KSpam wrote:
>>
>> Roland,
>>
>> On Wednesday 11 August 2010 01:37:17 Roland Bock wrote:
>>>
>>> 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
>>
>> This warning can be prevented by splitting the line into two lines as
>> follows:
>>
>> Replace:
>> reinterpret_cast<functor_type*>(&in_buffer.data)->~Functor();
>>
>> with:
>> functor_type* p = reinterpret_cast<functor_type*>(&in_buffer.data);
>> p->~Functor();
>>
>> I patched my local version of Boost in order to prevent these warnings.
>>
>> Hope This Helps,
>> Justin
>
> Justin,
>
> thanks for the hint! I'll give it a try and will probably file a ticket if
> it works out :-)

Also, you should file a ticket with GCC, two tickets actually: 1) a
trivial change like this should not have effect on the warning, and 2)
strict aliasing rules should not apply to char pointers (as far as I
can tell, in_buffer.data is of char type specifically to deal with
this issue.)

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net