Skip to content

Pattern matching with overlapping matches crash the compiler #12369

Closed
@haralkar

Description

@haralkar

The following code, compiled on Ubuntu 12.04.3 LTS Precise Pangolin - Release i386 (20130820.1) :

fn main() {
    let sl = ~[1,2,3];
    let v : int = match sl.as_slice() {
        [] => 0,
        [a,b,c] => 3,
        [a, ..rest] => a,
        [10,a, ..rest] => 10
    };
}

causes rustc to spew forth:

error: internal compiler error: unexpected failure
This message reflects a bug in the Rust compiler. 
We would appreciate a bug report: http://static.rust-lang.org/doc/master/complement-bugreport.html
note: the compiler hit an unexpected failure path. this is a bug
Ok(task 'rustc' failed at 'called `Option::unwrap()` on a `None` value', /home/haralkar/source/other/rust/src/libstd/option.rs:152
)

stack trace:

#0  0xb7b201f0 in rust_fail () from /usr/local/bin/../lib/libstd-966edb7e-0.10-pre.so
#1  0xb7b201ca in rt::unwind::Unwinder::begin_unwind::h0fb1c94e84003260fVl::v0.10.pre () from /usr/local/bin/../lib/libstd-966edb7e-0.10-pre.so
#2  0xb7a5b8fc in rt::unwind::begin_unwind_inner::h773d77f533ab0b7f63l::v0.10.pre () from /usr/local/bin/../lib/libstd-966edb7e-0.10-pre.so
#3  0xb4d92472 in rt::unwind::begin_unwind::hef0624ac43bd2c30lut::v0.10.pre () from /usr/local/bin/../lib/librustc-0d83f02f-0.10-pre.so
#4  0xb5115c1d in middle::check_match::is_useful_specialized::h2768080653796199dAv::v0.10.pre () from /usr/local/bin/../lib/librustc-0d83f02f-0.10-pre.so
#5  0xb511238a in middle::check_match::is_useful::he651c1f6fa4baa58Osv::v0.10.pre () from /usr/local/bin/../lib/librustc-0d83f02f-0.10-pre.so
#6  0xb510acc3 in middle::check_match::check_expr::h7a2f3f3075653f85L6u::v0.10.pre () from /usr/local/bin/../lib/librustc-0d83f02f-0.10-pre.so
#7  0xb511be40 in visit::walk_local::h62e699c47b530baa6Nx::v0.10.pre () from /usr/local/bin/../lib/librustc-0d83f02f-0.10-pre.so
#8  0xb510d091 in middle::check_match::CheckMatchVisitor.Visitor$LT$$LP$$RP$$GT$::visit_local::ha5f445c46fcd4cdeV4u::v0.10.pre () from /usr/local/bin/../lib/librustc-0d83f02f-0.10-pre.so
#9  0xb510f4b8 in visit::walk_decl::h56fc78a0011a49f22Mx::v0.10.pre () from /usr/local/bin/../lib/librustc-0d83f02f-0.10-pre.so
#10 0xb510f3a7 in visit::walk_stmt::h5a83bf7c9e1926ddKLx::v0.10.pre () from /usr/local/bin/../lib/librustc-0d83f02f-0.10-pre.so
#11 0xb510f300 in visit::walk_block::h5fe9aa45b8c870b51Gx::v0.10.pre () from /usr/local/bin/../lib/librustc-0d83f02f-0.10-pre.so
#12 0xb511c3ea in visit::walk_fn::h2d0a7d76b5928a56TXx::v0.10.pre () from /usr/local/bin/../lib/librustc-0d83f02f-0.10-pre.so
#13 0xb510d3c1 in middle::check_match::CheckMatchVisitor.Visitor$LT$$LP$$RP$$GT$::visit_fn::h5d86c04b034efca9h5u::v0.10.pre () from /usr/local/bin/../lib/librustc-0d83f02f-0.10-pre.so
#14 0xb510e166 in visit::walk_item::h2046ebdf6b6a01e8o6z::v0.10.pre () from /usr/local/bin/../lib/librustc-0d83f02f-0.10-pre.so
#15 0xb510d62c in middle::check_match::check_crate::h743fc3cd5a0af3f1Z5u::v0.10.pre () from /usr/local/bin/../lib/librustc-0d83f02f-0.10-pre.so
#16 0xb53a124c in driver::driver::phase_3_run_analysis_passes::closure () from /usr/local/bin/../lib/librustc-0d83f02f-0.10-pre.so
#17 0xb5105333 in util::common::time::h03cd35a5f105859447j::v0.10.pre () from /usr/local/bin/../lib/librustc-0d83f02f-0.10-pre.so
#18 0xb539e988 in driver::driver::phase_3_run_analysis_passes::h3d5ff619b94fc529sZh::v0.10.pre () from /usr/local/bin/../lib/librustc-0d83f02f-0.10-pre.so
#19 0xb53a41b6 in driver::driver::compile_input::hcf12d2e8a6a52e3f2mi::v0.10.pre () from /usr/local/bin/../lib/librustc-0d83f02f-0.10-pre.so
#20 0xb53c6f42 in run_compiler::haa0a4958670ee4faueq::v0.10.pre () from /usr/local/bin/../lib/librustc-0d83f02f-0.10-pre.so
#21 0xb53d800c in main_args::closure () from /usr/local/bin/../lib/librustc-0d83f02f-0.10-pre.so
#22 0xb53d6583 in monitor::closure () from /usr/local/bin/../lib/librustc-0d83f02f-0.10-pre.so
#23 0xb53d1c16 in task::TaskBuilder::try::closure () from /usr/local/bin/../lib/librustc-0d83f02f-0.10-pre.so
#24 0xb79bc808 in task::bootstrap_green_task::closure () from /usr/local/bin/../lib/libgreen-80d9e76a-0.10-pre.so
#25 0xb7b19659 in rt::task::Task::run::closure () from /usr/local/bin/../lib/libstd-966edb7e-0.10-pre.so
#26 0xb7b20134 in rt::unwind::Unwinder::try::try_fn::h7ffff9688f83cea7bUl::v0.10.pre () from /usr/local/bin/../lib/libstd-966edb7e-0.10-pre.so
#27 0xb7b23573 in rust_try () from /usr/local/bin/../lib/libstd-966edb7e-0.10-pre.so
#28 0xb7b1951b in rt::task::Task::run::he29d8027dadeaed4wvj::v0.10.pre () from /usr/local/bin/../lib/libstd-966edb7e-0.10-pre.so
#29 0xb79bc6d7 in task::bootstrap_green_task::h24b4ab701c781efax8b::v0.10.pre () from /usr/local/bin/../lib/libgreen-80d9e76a-0.10-pre.so
#30 0x00000000 in ?? ()

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions