-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-codegenArea: Code generationArea: Code generationA-trait-systemArea: Trait systemArea: Trait systemE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Description
Tested in rust 0.6 on Arch (Linux - 3.8.4, x86_64)
Modified testcase exhibits similar behavior on Mac OS X 10.7
I can call #bark()
on any index of the vector and it does not seg-fault.
When using the #each()
iterator however, only the first element is printed, the next access results in a segmentation fault.
I've been able to reproduce this on two separate systems, one running rust 0.6 (6dd20c8) on a fairly vanilla Linux kernel, the other running (release-0.5) on Mac OS X.
I've written a small test-case that exhibits this behavior on my systems.
Note
Please let me know if I can gather any additional information that might aid in resolving this issue.
struct Dog {
name : ~str
}
trait Barks {
fn bark(&self) -> ~str;
}
// impl Dog : Barks { //uncomment for Rust 0.5
impl Barks for Dog {
fn bark(&self) -> ~str {
return ~"bark (for ~Dog)";
}
}
fn main() {
let snoopy = ~Dog{name: ~"snoopy"};
let bubbles = ~Dog{name: ~"bubbles"};
let barker = [snoopy as ~Barks, bubbles as ~Barks];
for barker.each |pup| {
println(fmt!("%s", pup.bark()));
}
}
/* Expected:
* woof! (I'm snoopy)
* woof! (I'm bubbles)
*/
/* Actual Ouptut:
* woof! (I'm snoopy)
* SEGMENTATION FAULT
*/
Metadata
Metadata
Assignees
Labels
A-codegenArea: Code generationArea: Code generationA-trait-systemArea: Trait systemArea: Trait systemE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.