Closed
Description
I am very new to rust, so please bear with me :).
When trying to do a small routine to parse the arguments of a program, I stumbled on a nice segfault. Here is the prototype of what I tried.
fn parse_args() -> ~str {
let args = core::os::args();
let mut n = 0;
while n < args.len() {
match copy args[n] {
~"-v" => (),
s => {
return s;
}
}
n += 1;
}
return ~""
}
fn main() {
io::println(parse_args());
}
This example is meaningless and only illustrates the issue. I managed to write what I wanted in a cleanier style afterwards but I still think it's a bug.
It compiles without a warning but it crashes violently when running it.