<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Sun, 11 Feb 2018 at 19:29, Gabriel Dos Reis <<a href="mailto:gdr@microsoft.com">gdr@microsoft.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div lang="EN-US">
<div class="gmail-m_6759161928763791065WordSection1">
<p class="MsoNormal">Thank you for following through!<u></u><u></u></p>
<p class="MsoNormal">And taking care of the ‘memcpy’ and ‘memmove’ thingies.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">When we say that the operations implicitly creates an object, are we also to require that the bits patterns there be valid object representation? That would impose a severe restriction…</p></div></div></blockquote><div><br></div><div>I think we need to allow cases like this:</div><div><br></div><div>struct X { int a, b; };</div><div>X *p = (X*)malloc(sizeof(X));</div><div>p->a = 1;</div><div>p->b = 2;</div><div><br></div><div>... where there is not necessarily a valid object representation in the *p memory after the call to malloc, but we need for there to already be an object there for the p->a assignment to be valid.</div><div><br></div><div>I think we should say that the created object -- or at least its scalar subobjects -- contain an indeterminate value (the kind that means you get UB if you try to read it, <a href="http://eel.is/c++draft/dcl.init#12">http://eel.is/c++draft/dcl.init#12</a>) if the storage doesn't contain a valid object representation.</div><div><br></div><div>For example, given:</div><div><br></div><div>char c = 7;</div><div>bool b; // assuming sizeof(b) == 1</div><div>memcpy(&b, &c, 1);</div><div><br></div><div>'b' should have the same behavior as an uninitialized bool, because we "initialized" it with an invalid bool representation:</div><div><br></div><div>bool x = b; // undefined behavior</div><div><br></div><div>Does that seem reasonable to you?</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="EN-US"><div class="gmail-m_6759161928763791065WordSection1">
<div style="border-top:none;border-right:none;border-bottom:none;border-left:1.5pt solid blue;padding:0in 0in 0in 4pt">
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0in 0in">
<p class="MsoNormal"><b>From:</b> <a href="mailto:ub-bounces@open-std.org" target="_blank">ub-bounces@open-std.org</a> [mailto:<a href="mailto:ub-bounces@open-std.org" target="_blank">ub-bounces@open-std.org</a>]
<b>On Behalf Of </b>Richard Smith<br>
<b>Sent:</b> Friday, February 9, 2018 11:52 AM<br>
<b>To:</b> <a href="mailto:ub@open-std.org" target="_blank">ub@open-std.org</a><br>
<b>Subject:</b> [ub] new revision of p0593<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Hi all,<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Please find attached a revised version of P0593 based on the excellent discussion and feedback at the Albuquerque meeting. Please let me know if you have any comments; I believe our plan was to discuss this again at Jacksonville, and all
being well, to forward it to EWG at that meeting.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Best regards,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Richard<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
_______________________________________________<br>
ub mailing list<br>
<a href="mailto:ub@isocpp.open-std.org" target="_blank">ub@isocpp.open-std.org</a><br>
<a href="http://www.open-std.org/mailman/listinfo/ub" rel="noreferrer" target="_blank">http://www.open-std.org/mailman/listinfo/ub</a><br>
</blockquote></div></div>