<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Mar 11, 2014 at 2:41 PM, Marshall Clow <span dir="ltr"><<a href="mailto:mclow.lists@gmail.com" target="_blank">mclow.lists@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><div class=""><div>On Mar 11, 2014, at 2:14 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>> wrote:</div>
<br></div><div class=""><blockquote type="cite"><blockquote class="gmail_quote" style="font-family:LucidaGrande;font-size:11px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;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 style="word-wrap:break-word"><div>I’m open to suggestions here:</div><div>a) I can put the instance variable back, and never use it. No ABI break, but an unused iterator in every reverse iterator.</div></div></blockquote>
<div style="font-family:LucidaGrande;font-size:11px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
<br></div><div style="font-family:LucidaGrande;font-size:11px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
Any code that passes a reverse_iterator between TUs built against different libc++ versions would still not work.</div></blockquote><br></div></div><div>Ok, I missed this comment; I thought it applied to the change - not the proposed fix.</div>
<div>I disagree. I do not believe that putting the instance variable back and not using it will not break code across TUs.</div><div><br></div><div>The only use of the instance variable __t is in the operator*() for the reverse iterator, which used to say:</div>
<div class=""><div><span style="font-family:LucidaGrande"><span style="white-space:pre-wrap">     </span>_LIBCPP_INLINE_VISIBILITY reference operator*() const {__t = current; return *--__t;}</span></div></div><div>(i.e, the variable is set immediately before use)</div>
<div class=""><div>but now says:<br style="font-family:LucidaGrande"><span style="font-family:LucidaGrande"><span style="white-space:pre-wrap">   </span>_LIBCPP_INLINE_VISIBILITY reference operator*() const {_Iter __tmp = current; return *--__tmp;}</span><br style="font-family:LucidaGrande">
</div><div><br></div></div><div>The purpose of having this instance variable “stick around”, rather than being a local variable, was to support iterators whose operator* returned a reference to something inside of the iterator. If the iterator was a local variable, then the things contained inside of it would be destroyed when the iterator was destroyed.</div>
<div><br></div><div>However, in #2360, <a href="mailto:STL@microsoft.com" target="_blank">STL@microsoft.com</a> pointed out that this was inviting silent data races, and the LWG decided not to support those kind of iterators any more.</div>
<div>(see the comments on LWG issue #198, which #2360 partially reversed).</div><div><br></div><div>Richard — clearly you think otherwise.</div><div>I’d like to hear your explanation as to why.</div></div></blockquote><div>
<br></div><div>On further study, I think the approach you're talking about is fine. You'd need to keep the actual instance variable, not just storage appropriate for it (you still need to call the default constructor and destructor, if any), and you'll probably need it to still be 'mutable' to avoid more subtle changes.</div>
<div><br></div><div>(... and we should remove that member in the 'unstable ABI' mode when we have it!)</div></div></div></div>