Skip to content

Codegen bug: dest == expr::Ignore || bcx.unreachable.get() #11709

Closed
@alexcrichton

Description

@alexcrichton

Was trying to find another bug, found this bug!

#[inline(never)]                                             
fn function(slot: &mut Option<proc() -> proc()>, f: proc()) {
  let a = slot.take();                                       
  let a = match a {                                          
    Some(a) => { let _a = a(); },                            
    None => (),                                              
  };                                                         
  //a();                                                     
}                                                            
fn main() {                                                  
  let mut slot = None;                                       
  function(&mut slot, proc() {});                            
}                                                            

That code will fail with

[~/rust/valgrind[master]] $ rustc foo.rs -O && valgrind ./foo                                                                                                                        [alex@arch-vm]
foo.rs:2:50: 2:51 warning: unused variable: `f`, #[warn(unused_variable)] on by default
foo.rs:2 fn function(slot: &mut Option<proc() -> proc()>, f: proc()) {
                                                          ^
foo.rs:4:7: 4:8 warning: unused variable: `a`, #[warn(unused_variable)] on by default
foo.rs:4   let a = match a {
               ^
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
task 'rustc' failed at 'assertion failed: dest == expr::Ignore || bcx.unreachable.get()', /build/rust-git/src/rust/src/librustc/middle/trans/controlflow.rs:91

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions