Subject: Re: [Boost-users] [Spirit] dereferencing type-punned pointer will break strict-aliasing rules
From: KSpam (keesling_spam_at_[hidden])
Date: 2010-08-12 02:26:59


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