Boost logo

Boost Users :

Subject: Re: [Boost-users] [Review] Formal Review: Boost.Move
From: Neil Groves (neil_at_[hidden])
Date: 2010-05-21 07:35:01


2010/5/21 Ion Gaztañaga <igaztanaga_at_[hidden]>

> On 21/05/2010 9:37, Neil Groves wrote:
>
>> These reinterpret_cast operations violate the standard aliasing rules
>> AFAICT. Indeed while most compilers work happily with this arrangement.
>> I have reproduced defects with GCC 4.4 when optimizations are enabled.
>> Additionally if one enables the strict aliasing warnings these lines are
>> indicated as being incorrect.
>>
>
> What if we use static_cast? Does this solve any problem? I don't know much
> about aliasing rules so can you shed some light on this?
>
>
There was a bug logged against GCC 4.4 using a Boost.Move inspired snippet -
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44186

This bug was closed as invalid because the C99 aliasing rules are violated
by the casting. However by changing all of the reinterpret and c style casts
to static_casts technically renders this compliant due to Section 5.2.9 para
2. Therefore I believe static_casts provide a route to a performant and
standard compliant version.

Sadly I'm still having errors with my version on GCC 4.4 despite having
fixed the aliasing problems. The relevant GCC warnings have all disappeared
indicating that the aliasing is now compliant. I am continuing to
investigate why the generated code appears to be incorrect.

I'll perform a full review as soon as I possibly can.

> Best,
>
> Ion
>
> I hope this helps,
Neil Groves



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