<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Mar 7, 2014 at 2:43 PM, Aaron Ballman <span dir="ltr"><<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Fri, Mar 7, 2014 at 5:28 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br>

> On Fri, Mar 7, 2014 at 2:17 PM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>> wrote:<br>
>> Author: aaronballman<br>
>> Date: Fri Mar  7 16:17:20 2014<br>
>> New Revision: 203299<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=203299&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=203299&view=rev</a><br>
>> Log:<br>
>> In my tests, I'm finding that declaring iterators in terms of ranges can sometimes have dangerous side-effects where the range temporary is destroyed, taking the underlying iterators out with it.<br>
><br>
> Um... what? do you have a concrete example because that doesn't sound<br>
> right at all, at least not for iterator_range<T> which just holds<br>
> copies of the iterator - are some of our iterators non-copyable (or<br>
> not safely/sanely copyable in some way)? All the begin/end's return by<br>
> value, so I don't see how they could be related to the copy that<br>
> happens to be in the range temporary...<br>
<br>
</div>I've found this to be the case anywhere the iterator doesn't wind up<br>
being a simple pointer. attributes (which I had to roll back),</blockquote><div><br></div><div>I thought the problem in the attributes case was that an accidental copy of the collection of attributes was being made? Or does this still break with that fixed?</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">enums<br>
(which I've yet to commit while trying to figure this out). In all<br>
cases, the commonality is that it compiles fine, but exhibits<br>
use-after-free behavior on test cases in some circumstances.<br>
<br>
Regarding the attribute patch (which was committed this morning as<br>
r203236 and reverted as r203237), Takumi found that these specific<br>
changes were causing test cases to fail:<br>
<a href="https://gist.github.com/chapuni/9412576" target="_blank">https://gist.github.com/chapuni/9412576</a><br>
<br>
So I agree, I find is really surprising that it behaves this way, but<br>
prefer to err on the side of caution at least while doing this initial<br>
push. Once things are pretty well range-ified, then I intend to<br>
revisit the problem (unless someone beats me to it).</blockquote><div><br></div><div>Does this happen with multiple compilers, or is it an MSVC-specific miscompile? </div></div></div></div>