<div dir="ltr">It did not change anything, as we are not dereferencing iterator after delete.<div><br></div><div>I think changing:</div><div>delete *it;<br>uses.erase(it);<br><div><br></div><div>to:<br><div>use_info *ptr = *it;</div><div>uses.erase(it);</div><div>delete ptr;</div><div><br></div><div>don't make it more readable or safer, but I can change it if you want to. </div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 30, 2017 at 3:16 PM, Nicolai Hähnle <span dir="ltr"><<a href="mailto:nhaehnle@gmail.com" target="_blank">nhaehnle@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Nice find!<span class=""><br>
<br>
On 29.01.2017 19:10, Bartosz Tomczyk wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
---<br>
src/gallium/drivers/r600/sb/s<wbr>b_valtable.cpp | 8 +++++++-<br>
1 file changed, 7 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/src/gallium/drivers/r600/sb/<wbr>sb_valtable.cpp b/src/gallium/drivers/r600/sb/<wbr>sb_valtable.cpp<br>
index a8b7b49cd4..d31a1b76d5 100644<br>
--- a/src/gallium/drivers/r600/sb/<wbr>sb_valtable.cpp<br>
+++ b/src/gallium/drivers/r600/sb/<wbr>sb_valtable.cpp<br>
@@ -241,6 +241,7 @@ void value::remove_use(const node *n) {<br>
{<br>
// TODO assert((*it)->kind == kind) ?<br>
// TODO assert((*it)->arg == arg) ?<br>
+ delete *it;<br>
uses.erase(it);<br>
</blockquote>
<br></span>
The delete should really be after the erase.<br>
<br>
Cheers,<br>
Nicolai<div class="HOEnZb"><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
}<br>
}<br>
@@ -290,7 +291,12 @@ bool value::is_prealloc() {<br>
}<br>
<br>
void value::delete_uses() {<br>
- uses.erase(uses.begin(), uses.end());<br>
+ for (uselist::iterator it = uses.begin(); it != uses.end(); ++it)<br>
+ {<br>
+ delete *it;<br>
+ }<br>
+<br>
+ uses.clear();<br>
}<br>
<br>
void ra_constraint::update_values() {<br>
<br>
</blockquote>
<br>
</div></div></blockquote></div><br></div>