Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding self parameter to trait causes code to segfault #4850

Closed
mcpherrinm opened this issue Feb 8, 2013 · 4 comments
Closed

Adding self parameter to trait causes code to segfault #4850

mcpherrinm opened this issue Feb 8, 2013 · 4 comments
Labels
A-codegen Area: Code generation A-traits Area: Trait system I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

Comments

@mcpherrinm
Copy link
Contributor

The following snippet segfaults when run. Removing the "self" parameters to thingie makes it not segfault, but makes rustc tell me that form is deprecated.

pub trait TestTrait {
  fn thingie(self) -> ~[u8];
}

impl ~[u8]: TestTrait {
  fn thingie(self) -> ~[u8] {
    ~[0u8]
  }
}

fn main() {
  let n = ~[];
  n.thingie();
}
@ghost ghost assigned catamorphism Feb 20, 2013
@graydon
Copy link
Contributor

graydon commented Mar 20, 2013

reproduced on 2013-03-20, seems imporant-ish

@catamorphism
Copy link
Contributor

Doesn't fail if I change self to &self, so I think the problem has to do with self being by-move.

@thestinger
Copy link
Contributor

#4355 is possibly related

dotdash added a commit to dotdash/rust that referenced this issue Jun 2, 2013
For types that are passed by value, we can't just cast the value to a
pointer, but have to use an alloca and copy the value there. This
handling is already present for all other arguments, but was missing
for "self".

Fixes rust-lang#6682, rust-lang#4850 and rust-lang#4878
bors added a commit that referenced this issue Jun 3, 2013
For types that are passed by value, we can't just cast the value to a
pointer, but have to use an alloca and copy the value there. This
handling is already present for all other arguments, but was missing
for "self".

Fixes #6682 #4850 #4878
@dotdash
Copy link
Contributor

dotdash commented Jun 27, 2013

This is fixed on master

bors added a commit that referenced this issue Jun 28, 2013
@luqmana luqmana closed this as completed Jun 28, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation A-traits Area: Trait system I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Projects
None yet
Development

No branches or pull requests

6 participants