<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="fn main() {                                                                                                                                                    
    let mut a = [0, 1, 2, 3];                                                                                                                                  
    let b = vec::filter(a) {|c|                                                                                                                                
        a = [];                                                                                                                                                
        true                                                                                                                                                   
    };                                                                                                                                                         
}  "><pre class="notranslate"><code class="notranslate">fn main() {                                                                                                                                                    
    let mut a = [0, 1, 2, 3];                                                                                                                                  
    let b = vec::filter(a) {|c|                                                                                                                                
        a = [];                                                                                                                                                
        true                                                                                                                                                   
    };                                                                                                                                                         
}  
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="==18087== Thread 8:
==18087== Invalid read of size 8
==18087==    at 0x4012C6: vec::filter1::_6a4a1114ba818cf3 (in /home/banderson/Dev/rust2/build/x86_64-unknown-linux-gnu/test/run-pass/test.stage1-x86_64-unknown-linux-gnu)
==18087==    by 0x400FBE: main::_843f8e32b1779b32 (in /home/banderson/Dev/rust2/build/x86_64-unknown-linux-gnu/test/run-pass/test.stage1-x86_64-unknown-linux-gnu)
==18087==    by 0x4010E9: _rust_main (in /home/banderson/Dev/rust2/build/x86_64-unknown-linux-gnu/test/run-pass/test.stage1-x86_64-unknown-linux-gnu)
==18087==    by 0x54C3E3A: task_start_wrapper(spawn_args*) (rust_task.cpp:176)
==18087==  Address 0x67ec620 is 16 bytes inside a block of size 48 free'd
==18087==    at 0x4C282ED: free (vg_replace_malloc.c:366)
==18087==    by 0x54D82B8: ??? (in /home/banderson/Dev/rust2/build/x86_64-unknown-linux-gnu/stage1/lib/rustc/x86_64-unknown-linux-gnu/lib/librustrt.so)
==18087== 
"><pre class="notranslate"><code class="notranslate">==18087== Thread 8:
==18087== Invalid read of size 8
==18087==    at 0x4012C6: vec::filter1::_6a4a1114ba818cf3 (in /home/banderson/Dev/rust2/build/x86_64-unknown-linux-gnu/test/run-pass/test.stage1-x86_64-unknown-linux-gnu)
==18087==    by 0x400FBE: main::_843f8e32b1779b32 (in /home/banderson/Dev/rust2/build/x86_64-unknown-linux-gnu/test/run-pass/test.stage1-x86_64-unknown-linux-gnu)
==18087==    by 0x4010E9: _rust_main (in /home/banderson/Dev/rust2/build/x86_64-unknown-linux-gnu/test/run-pass/test.stage1-x86_64-unknown-linux-gnu)
==18087==    by 0x54C3E3A: task_start_wrapper(spawn_args*) (rust_task.cpp:176)
==18087==  Address 0x67ec620 is 16 bytes inside a block of size 48 free'd
==18087==    at 0x4C282ED: free (vg_replace_malloc.c:366)
==18087==    by 0x54D82B8: ??? (in /home/banderson/Dev/rust2/build/x86_64-unknown-linux-gnu/stage1/lib/rustc/x86_64-unknown-linux-gnu/lib/librustrt.so)
==18087== 

</code></pre></div>
<p dir="auto">Running this program:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="use std;
import std::io;

fn iter(&amp;&amp;v: [uint], f: fn(uint)) {
    for i in v { f(i) }
}

fn main(args: [str]) {
    let v = vec::enum_uints(0u, 10u);
    iter(v) { |i|
         v = [];
         io::print(#fmt[&quot;i=%?\n&quot;, i]);
    }
}"><pre class="notranslate"><code class="notranslate">use std;
import std::io;

fn iter(&amp;&amp;v: [uint], f: fn(uint)) {
    for i in v { f(i) }
}

fn main(args: [str]) {
    let v = vec::enum_uints(0u, 10u);
    iter(v) { |i|
         v = [];
         io::print(#fmt["i=%?\n", i]);
    }
}
</code></pre></div>
<p dir="auto">yields this output</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="i=0
i=2
i=171048973
i=1979117988610105
i=4122818071364057393
i=3978138846657458487
i=3979273541751617588
i=51
i=17293822612877934602
i=17293822569102704640
i=9"><pre class="notranslate"><code class="notranslate">i=0
i=2
i=171048973
i=1979117988610105
i=4122818071364057393
i=3978138846657458487
i=3979273541751617588
i=51
i=17293822612877934602
i=17293822569102704640
i=9
</code></pre></div>
<p dir="auto">I expected a compile error.</p>