Type-based aliasing in C
The float&#x2F;int aliasing via pointer is the strawman version of this which is used to sell the undefinedness and the optimizations as a good thing.<p>In fact, int&#x2F;<i>int</i> aliasing is also undefined behavior:<p><pre><code>   {
     struct foo { int x; } sfoo = { 42; };
     struct bar { int x; } *psbar = (struct bar *) &amp;sfoo;

     return psbar-&gt;x; &#x2F;&#x2F; UB, even though int accessed.
   }
</code></pre>
Why this is undefined ias that psbar-&gt;x is actually (* psbar).x. There is an lvalue ere which is (* psbar) and that is of type struct bar; it doesn&#x27;t match the type of the object which is struct foo.<p>Maybe it&#x27;s time for an alternative to ISO C: a safe C with more behaviors pinned down.<p>It should be that when an lvalue is formed by a chained expression like a-&gt;b[2].c.d the type of the access should be considered to be the final type which designates the data object, without regard for the intermediate types in the chain. The object should be deemed to be accessed via that type.  So if the .d member in a-&gt;b[2].c.d has type int, and the object being designated has that type, everything is good.