Closed
Description
openedon Jun 28, 2012
This segfaults:
iface hax { }
impl <A> of hax for A { }
fn perform_hax<T>(x: @T) -> hax {
x as hax
}
fn deadcode() {
perform_hax(@"deadcode");
}
fn main() {
let _ = perform_hax(@42);
}
When the destructor for _ runs at the end of main, it tries to destroy @42 as though it were an @str, causing a call to free((void*)42).
It runs without segfaulting if the call in deadcode() is commented out. That call causes perform_hax(x) to get monomorphised to promote x as hax as though x were @str. With the call gone, the first monomorphisation happens at main's call, for @int.
It runs without segfaulting if deadcode() and main() are reordered lexicographically, for the same reason as above.
It runs without segfaulting if perform_hax is manually inlined (so that there are two '... as hax').
It runs without segfaulting if "let _ =" is removed in main. Filing a separate issue for that.
Activity