Skip to content

Segmentation fault with rust 0.12.0 nightly : traits and references #15660

Closed
@artella-coding

Description

@artella-coding

The following compiles fine, but gives a segmentation fault upon running (Ubuntu 14.04 64 bit) :

struct Stuff {
  items : [Box<int>,..3]
}

impl Index<uint,Box<int>> for Stuff {
  fn index<'a>(&'a self, i: &uint) -> &'a Box<int> {
    return &self.items[*i];
  }
}

fn main(){
  let val = Stuff {items:[box 0,box 1,box 2]};
  let val2 = val[1];
  let val2 = val[1];
  println!("{}",val2);
}

and I am using :

rustc 0.12.0-pre-nightly (3d70f50b2ce2e04bb8db934721eeaddb80a7cc27 2014-07-14 00:31:30 +0000)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions