<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Nov 25, 2016 at 1:42 AM, Daniel Berlin <span dir="ltr"><<a target="_blank" href="mailto:dberlin@dberlin.org">dberlin@dberlin.org</a>></span> wrote:<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div dir="ltr">What is the purpose of the union there?<br></div></blockquote><div>The
purpose of the union is to increase portability by ensuring that the
placement new is not being performed on insufficiently sized or aligned
memory.<br> </div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div dir="ltr">I ask because pretty much no compiler will respecting the unioning without visible accesses in all cases, because it would ruin most optimization[1]<div><br></div><div>But i'm also not sure it's required in this testcase to make your testcase fail.</div></div></blockquote><div>It isn't. The program should be valid, without the union, on platforms where <span style="font-family:monospace,monospace">int</span> and <span style="font-family:monospace,monospace">float</span> have the same size an alignment.<br></div><div> </div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div dir="ltr"><div><br></div><div>In practice, handling placement new properly in gcc required the equivalent of a new intrinsic (in gcc, it required adding CHANGE_DYNAMIC_TYPE_EXPR).</div></div></blockquote><div>Sure; my question is whether or not there is already a solution in the works for LLVM. If not, then I'll try to work with some folks to propose an intrinsic.<br><br></div><div>-- HT<br></div></div></div></div>