Re:The Strict Aliasing Situation Is Pretty Bad
by haberman on Tuesday March 15, 2016 @09:44AM
(#11289513)
Pretty sure it's safe! Take this program:
Notice that if we are accessing the base members of "d", we are still accessing them through a struct of type "Base" (d->base.x). If we compile this with strict aliasing, you can see the output is allowing that the two might alias (while this isn't a proof, it's a strong indication that this is aliasing-correct).
[ Parent
| on HN ]
Re:The Strict Aliasing Situation Is Pretty Bad
by vc98mvco on Tuesday March 15, 2016 @09:53AM
(#11289580)
It is defined.
6.5.7. An object shall have its stored value accessed only by an lvalue expression that has one of the following types:
- an aggregate or union type that includes one of the aforementioned types among its members (including, recursively, a member of a subaggregate or contained union)
This means Derived is allowed to alias Base.
Re:The Strict Aliasing Situation Is Pretty Bad
by TorKlingberg on Tuesday March 15, 2016 @10:43AM
(#11289946)
Thanks, this is good to know.