<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Jan 16, 2014 at 2:21 PM, Jens Maurer <span dir="ltr">&lt;<a href="mailto:Jens.Maurer@gmx.net" target="_blank">Jens.Maurer@gmx.net</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">On 01/16/2014 11:05 PM, Matt Austern wrote:<br>

&gt; That&#39;s an interesting possibility that I hadn&#39;t considered. It&#39;s definitely appealing in some ways, but I think that it, too, would imply some pretty big surgery in some pretty fundamental parts of the standard. So let&#39;s consider the following code snippet:<br>

&gt;   struct MyPOD { int x; }; // 1<br>
&gt;   void* vp = malloc(sizeof(MyPOD)); // 2<br>
&gt;   MyPOD* p1 = static_cast&lt;MyPOD*&gt;(vp); // 3<br>
&gt;   MyPOD* p2 = new MyPOD; // 4<br>
&gt;<br>
&gt; So the basic question I&#39;d ask is: after line 4, what are you allowed<br>
&gt; to do with p1 and what are allowed to do with p2, and how do the<br>
&gt; answers differ? We&#39;ve got a couple of choices.<br>
&gt;<br>
&gt; First choice: we decide that you aren&#39;t allowed to do anything that<br>
&gt; involves dereferencing p1, since p1 doesn&#39;t point to an object.<br>
<br>
</div>Please don&#39;t confuse &quot;object&quot; with &quot;lifetime&quot;.<br>
<br>
1.8p1 says an object is a region of storage.  Both *p1 and<br>
*p2 satisfy that.<br></blockquote><div><br></div><div>That&#39;s an interesting observation. It&#39;s also true, of course, that</div><div>  void* vp = malloc(12);</div><div>creates a region of storage and thus, by the definition in 1.8p1,</div>
<div>creates an object. I&#39;m a little reluctant to say that this line</div><div>creates an object of type T, though, no matter what T is. Maybe</div><div>we have subtly different concepts of &quot;object&quot;, &quot;object of type T&quot;,</div>
<div>and &quot;object whose lifetime has begun&quot;. Or maybe we need to</div><div>make those subtle distinctions even we aren&#39;t currently making</div><div>them.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<br>
Further, 3.8p1 seems to say that the lifetime of both *p1 and *p2<br>
has begun.</blockquote><div><br></div><div>I agree that 3.8p1 seems to say that. Not everyone seems to</div><div>agree that it says that, though; some people also seem to think</div><div>that even if it does say that, it shouldn&#39;t. I sympathize. That</div>
<div>reading of 3.8p1 has some surprising consequences. (But every</div><div>proposed alternative I can think of seems to have some</div><div>surprising consequences too.)</div><div><br></div><div>                                 --Matt</div>
</div></div></div>