Boost logo

Boost :

Subject: Re: [boost] [optional] Strict Aliasing Warnings on Trunk
From: Patrick Horgan (phorgan1_at_[hidden])
Date: 2009-12-22 21:50:12


Paul A. Bristow wrote:
> After reading this exchange, am I right in adding this to the GCC 'what to do about warnings' guidelines section at
>
> https://svn.boost.org/trac/boost/wiki/Guidelines/MaintenanceGuidelines?
>
> "
> warning: dereferencing pointer ‘<anonymous>’ does break strict-aliasing rules
>
> This warns about undefined behaviour that is likely to cause unwanted results when optimisation is switched on.
>
> Recommendation: Fix this by recoding if possible, and document that optimisation may produce wrong results.
> Include a link to the above example email.
>
> Do not suppress the warning with -Wno-strict-warnings - leave that to users after reading the documentation or making their own tests / compile without optimisation.
>
It's a lot more complex then that. Sometimes that warning comes from
safe type punning such as the placement use in boost optional. I've not
convinced myself (yet) that it can't go awry with optimization, in that
the optimizer could ignore type-punned access and when you try to
retrieve the value get an optimized original value, but others who are
quite intelligent and muchly more familiar with it than I believe so.

I'm definitely in favor of something like this. I've started working on
something myself I wanted to put on that page covering common gcc
warnings (mostly drawn from warnings from compiling and using boost),
their causes and the fixes, and at 268 lines it's getting tomeish. My
post in this conversation came from that document via the magic of cut
and paste.

Patrick


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk