-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-codegenArea: Code generationArea: Code generationA-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
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.
Metadata
Metadata
Assignees
Labels
A-codegenArea: Code generationArea: Code generationA-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.