
On Thu, Jun 21, 2012 at 9:46 PM, Ion Gaztañaga <igaztanaga@gmail.com> wrote:
El 20/06/2012 19:54, Tr3wory escribió:
But rv<TYPE> is derived from TYPE so to me it looks like the two type is compatible, therefore the code didn't violate the strict aliasing rules, so the attribute is not necessary. (BTW can we violate the strict aliasing rules trough static_cast if we don't do any chained conversion trough void*?)
It might not break strict aliasing (I'm not an expert) but it is undefined behavior to static_cast down a hierarchy to a type that isn't actually the type of the object. Boost.Move uses this undefined behavior hole and the GCC behavior is fixed with may_alias. I haven't found a better solution.
So if I understand you correctly, we are in the field of undefined behavior either way. Did you experience any problem with gcc what you solved with may_alias, or it's just the materialization of the idea of "better safe than sorry"? tr3w