<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 22, 2015 at 5:26 PM, Daniel Cheng via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">dcheng added a comment.<br>
<span class=""><br>
In <a href="http://reviews.llvm.org/D13080#251324" rel="noreferrer" target="_blank">http://reviews.llvm.org/D13080#251324</a>, @dblaikie wrote:<br>
<br>
> I'd still be curious to see a stronger justification from the standard<br>
>  about this.<br>
><br>
> I know you mentioned/quoted the definition of ~unique_ptr in the standard -<br>
>  but I'm not sure that is meant to imply observable behavior during<br>
>  destruction (though I could be wrong). Is there anything in the standard<br>
>  about accessing objects while their dtors are executing?<br>
<br>
<br>
</span>From 3.8.5 [basic.life]:<br>
Before the lifetime of an object has started but after the storage which the object will occupy has been<br>
allocated or, after the lifetime of an object has ended and before the storage which the object occupied is<br>
reused or released, any pointer that refers to the storage location where the object will be or was located<br>
may be used but only in limited ways. For an object under construction or destruction, see 12.7.<br>
<br>
>From 12.7.1 [class.dtor]:<br>
For an object with a non-trivial destructor, referring to any non-static member or base class of the object after the destructor finishes execution results in undefined behavior.<br>
<br>
So I believe the standard permits object access while the dtor is still executing.<br></blockquote><div><br></div><div>Thanks for the wording - seems plausible.<br><br>My other hesitation here is: if the object being destroyed needs to use itself through the pointer in the unique_ptr, isn't it already fragile/broken? If the unique_ptr was reset or set to null, etc, before destruction happened it would fail in the same way it is failing now? So it's not safe to be held by a unique_ptr, really... </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
<br>
<a href="http://reviews.llvm.org/D13080" rel="noreferrer" target="_blank">http://reviews.llvm.org/D13080</a><br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div></div>