<div dir="ltr">Sorry for bumping an old thread, but I ended up trying to pick up the project that brought this up again after<div>giving up last year because of the analyzer's lacking union support. Naturally I ran into the same problems again :/.</div><div>It seems like the first step here is to decide what model of unions the analyzer intends to support. I'd be</div><div>happy to try fix some things here, but of course those decisions need to be made first.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 3, 2017 at 2:12 AM, Aaron Ballman <span dir="ltr"><<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Thu, Mar 2, 2017 at 8:54 PM, Keno Fischer <<a href="mailto:keno@juliacomputing.com">keno@juliacomputing.com</a>> wrote:<br>
> This behavior also differs between C and C++. For example, C has explicitly:<br>
><br>
> [N1570, Footnote 95]<br>
> If the member used to read the contents of a union object is not the<br>
> same as the member last used to store a value in the object, the<br>
> appropriate part of the object representation of the value is<br>
> reinterpreted as an object representation in the new type as described<br>
> in 6.2.6 (a process sometimes called ‘‘type punning’’). This might be<br>
> a trap representation.<br>
><br>
> where object representation is essentially what you'd get if you<br>
> memcpyed the value.<br>
<br>
</div></div>Yes, if everything lines up just perfectly, then in C this may be<br>
okay. I say may because it can still be a trap representation, it<br>
could be a misaligned access, there could be unspecified values within<br>
the union member, etc (so it depends on the types and the specific<br>
values), so it is *not* strictly a safe operation to do in C either.<br>
<span class="HOEnZb"><font color="#888888"><br>
~Aaron<br>
</font></span></blockquote></div><br></div>