<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Jun 19, 2012, at 6:30 PM, Jordan Rose wrote:</div><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Jun 19, 2012, at 18:25 , Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:</div><blockquote type="cite"><blockquote type="cite" style="font-family: monospace; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">I believe the intent of the standard is quite clearly to have the local<br>variable destroyed in reverse order of construction w.r.t. the temporaries,<br>much like a return value must be.<br></blockquote><br style="font-family: monospace; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span style="font-family: monospace; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none; ">That does not match my expectation, which is that in:</span><br style="font-family: monospace; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><br style="font-family: monospace; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span style="font-family: monospace; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none; "> S s(T(), T());</span><br style="font-family: monospace; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><br style="font-family: monospace; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span style="font-family: monospace; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none; ">the T temporaries should *always* be destroyed before the S object is.</span><br style="font-family: monospace; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "></blockquote><br></div><div>To take this a step further, if the code looked like this:</div><div><br></div><div>{</div><div> S s(T(), T());</div><div> doSomethingElse();</div><div>}</div><div><br></div><div>…the S object should not be destroyed until doSomethingElse() finishes. The T objects, OTOH, will be destroyed at the end of the S object's decl statement (or thereabouts).</div><div><br></div><div>But if I /remove/ the call to doSomethingElse(), suddenly the S object is destroyed first?</div></div></blockquote><div><br></div>Along normal control flow, there's no debate this we always see this:</div><div> temp1.T();</div><div> temp2.T();</div><div> s(temp1, temp2); // assuming left-to-right evaluation for sake of argument</div><div> temp2.~T();</div><div> temp1.~T();</div><div> doSomethingElse(); // if present</div><div> s.~S();</div><div><br></div><div>Annotating this with exceptional edges, we would have:</div><div> temp1.T(); // resume</div><div> temp2.T(); // temp1.~T(); resume</div><div> s(temp1, temp2); // temp2.~T(); temp1.~T(); resume</div><div> temp2.~T(); // ??</div><div> temp1.~T(); // s.~S(); resume</div><div> doSomethingElse(); // s.~S(); resume</div><div> s.~S(); // resume</div><div> </div><div><div>The presence of doSomethingElse does not affect the ordering here, and I'm not sure why you're suggesting that my interpretation would make it so. The only question is what the ordering of destructors is out of temp2.~T().</div><div><br></div><div>I'll respond to Richard in more detail.</div><div><br></div></div><div>John.</div></body></html>