<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, May 3, 2016 at 4:35 PM, Tim Shen via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@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"><div dir="ltr"><div class="gmail_quote"><span class=""><div dir="ltr">On Thu, Apr 28, 2016 at 11:54 AM Richard Smith wrote:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>but not to do this:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div>1) call ~B()</div><div>2) end lifetime of B temporary</div><div>3) end lifetime of int temporary</div><div>4) call ~A()</div><div>5) end lifetime of A temporary</div></div></div></div></blockquote><div><br></div></span><div>Does this apply to non-temporaries?</div></div></div></blockquote><div><br></div><div>Yes.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div>For:</div><div><span class=""><div><br></div><div>struct A { ~A(); };</div><div>struct B { ~B(); };</div></span><div>void Bar(int&);</div><div>void Foo() {</div><div>  B b;</div><div>  int c;</div><div>  A a;</div><div>  Bar(c);</div><div>} </div></div><div><br></div><div>Today Clang generates:</div><div><div>  call void @_ZN1AD1Ev(%struct.A* nonnull %a) #4</div><div>  call void @llvm.lifetime.end(i64 1, i8* %2) #4</div><div>  call void @llvm.lifetime.end(i64 4, i8* %1) #4</div><div>  call void @_ZN1BD1Ev(%struct.B* nonnull %b) #4</div><div>  call void @llvm.lifetime.end(i64 1, i8* %0) #4</div></div><div><br></div><div>which is exactly what we want to avoid for now.</div></div></div></blockquote><div><br></div><div>Yep, this is technically a bug. (As mentioned, I'm working on getting the standard fixed to be a bit less ridiculous here. We'll see how that goes.)</div></div></div></div>