<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body bgcolor="#FFFFFF"><div>I know the standard, the problem is with the code, as I said the remove seems to be done in other function with no visibility of the "potentially broken" iterators.</div><div><br></div><div>That's why I asked if this code has owner.</div><div><br></div><div>Imho, the safest way to fix this is to change the code to use index and check vector size every loop, the bad thing is performance and clarity, but without a deeper understanding of this optimization Is difficult to fix.<br><br>I don't mind to change this code to use indices, if there is not any better choice. </div><div><br></div><div>Unai<br>Sent from my iPhone</div><div><br>On 24/07/2012, at 19:46, "Matthieu Monrocq" <<a href="mailto:matthieu.monrocq@gmail.com">matthieu.monrocq@gmail.com</a>> wrote:<br><br></div><div></div><blockquote type="cite"><div><br><br><div class="gmail_quote">On Tue, Jul 24, 2012 at 2:22 PM, Unai Landa <span dir="ltr"><<a href="mailto:ulanda@digital-legends.com" target="_blank">ulanda@digital-legends.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div>
<div style="direction:ltr;font-size:13px;font-family:Tahoma">
<div>After debuging I have been able to fix the issue;</div>
<div> </div>
<div> </div>
<div>I changed 2 lines on PeepholeOptimizer.cpp </div>
<div>Line 410:</div>
<div>from: <font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">for</font></font></font><font face="Consolas"><font face="Consolas"> (MachineFunction::iterator
 I = MF.begin(), E = MF.end(); I != E; ++I) {</font></font>
<p><font face="Consolas"><font face="Consolas">to:  </font></font><font face="Consolas"><font face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">for</font></font></font><font face="Consolas"><font face="Consolas">
 (MachineFunction::iterator I = MF.begin(); I !=MF.end(); ++I) {</font></font></font></font></p>
<p><font face="Consolas"><font face="Consolas"><font face="Consolas"><font face="Consolas"></font></font></font></font> </p>
<p><font face="Consolas"><font face="Consolas"><font face="Consolas"><font face="Consolas">And line 421</font></font></font></font></p>
<p><font face="Consolas"><font face="Consolas"><font face="Consolas"><font face="Consolas">from: <font face="Consolas"><font face="Consolas">MII = I->begin(), MIE = I->end(); MII != MIE; ) {</font></font></font></font></font></font></p>

<p><font face="Consolas"><font face="Consolas">to:  
<font face="Consolas"><font face="Consolas">MII = I->begin() ; MII != I->end(); ) {</font></font></font></font></p>
<p><font face="Consolas"><font face="Consolas"><font face="Consolas"><font face="Consolas"></font></font></font></font> </p>
<p><font face="Consolas"><font face="Consolas"><font face="Consolas"><font face="Consolas">This fixes teh problem, but I suspect that it comes from
<font face="Consolas"><font face="Consolas">OptimizeExtInstr as it seems removesome items from the vector.</font></font></font></font></font></font></p>
<p><font face="Consolas"><font face="Consolas"><font face="Consolas"><font face="Consolas"><font face="Consolas"><font face="Consolas"></font></font></font></font></font></font> </p>
<p>I'll do a full rebuild with this change and check if this fixes my issues.</p>
<p> </p>
<p>How should I manage this change? my fix, should work, but the may be the issue is located at other function, does the
<font color="#008000" face="Consolas"><font color="#008000" face="Consolas"><font color="#008000" face="Consolas"><font color="#000000">PeepholeOptimizer.cpp have owner?</font></font></font></font></p>

<p> </p>
<p><font face="Consolas"><font face="Consolas"><font face="Consolas"><font face="Consolas"><font face="Consolas"><font face="Consolas">Unai.<font face="Consolas"><font face="Consolas"></font></font></font></font></font></font></font></font></p>
<br></div></div></div></blockquote><div><br>Note: if items are removed from a vector, then the current iterator should be reassigned to too, as in<br><br><div style="margin-left:40px">V::iterator it = v.begin();<br>it = v.erase(it);<br>
</div><br>Even though for vector it is likely to still work without this (as they are probably barebone pointers under the cover), a debug version of a STL would catch the use of `it` after the call to erase with an assertion.<br>
<br>If you correct the loops checks, could you also take care of updating the iterator's value ?<br><br>-- Matthieu <br></div></div>
</div></blockquote></body></html>