-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Assertion failed: "Ptr must be a pointer to Val type!" #17257
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
Comments
Ran into this assertion while compiling retep998/ftb-rs@27ce2aa on win64.
|
This will engender the bug as well:
|
This example crashes on the same assert.
Interestingly, it does not fail to compile when
|
I also see this for this minimal version of this project. |
Another (as minimal as I could get it) reproduction on extern "C" fn foo(_: Blah) { }
struct Blah {
_ptr: extern "C" fn(Blah)
}
fn main() {
Blah { _ptr: foo };
}
Note that there is no assertion failure without the |
Another case that causes the same error (but for all I know could have a completely different cause): struct Foo<Sized? T> {
x: u8,
y: T,
}
fn main() {
let foo: &Foo<[int]> = &Foo { x: 1, y: [1i, 2, 3] };
match *foo {
Foo { x, ref y } => {},
}
} |
Here's a shorter example for unboxed closures: #![feature(unboxed_closures)]
fn main() {
let i = 0i;
let some_closure = |&: | {
let _capture = i;
};
} Compiling with
If you specify It also compiles correctly if don't capture anything from within the closure. Reproduced on:
|
Test are broken with a regression that crashes the compiler on an unboxed closure which captures some environment: rust-lang/rust#17257 As this only happens with debuginfo on, this temporarily disables it for dev & test. This should make Travis happy again.
A few variations on the example from @mdup that do and don't compile. Implicit return: no failure fn build_car<'a>() -> Box<Vehicle + 'a> {
box Car
} Explicit return, no closing semicolon: failure fn build_car<'a>() -> Box<Vehicle + 'a> {
return box Car
} Explicit return, closing semicolon: no failure fn build_car<'a>() -> Box<Vehicle + 'a> {
return box Car;
} Explicit return, cast, both closing and no closing semicolon: no failure fn build_car<'a>() -> Box<Vehicle + 'a> {
return box Car as Box<Vehicle>;
} In loop, explicit return, both closing and no closing semicolon: failure fn build_car<'a>() -> Box<Vehicle + 'a> {
loop {
return box Car;
}
} In loop, explicit return, cast, both closing and no closing semicolon: no failure fn build_car<'a>() -> Box<Vehicle + 'a> {
loop {
return box Car as Box<Vehicle>;
}
} |
The bug is [1] and it ought to be fixed at some point. [1] rust-lang/rust#17257
Updating for current Rust (on playpen): I was unsure how to update @rozaliev's example because of object safety errors. @pnathan's example compiles fine: fn read_file(path : String) -> Box<[u8]> {
return Box::new([])
}
fn main() {
} @mdup's example compiles fine: trait Vehicle { fn stuff(&self) {} }
struct Car;
impl Vehicle for Car { }
fn build_car<'a>() -> Box<Vehicle + 'a> {
loop {
return Box::new(Car);
}
}
fn main() { } @tomjakubowski's example compiles fine as is. @P1start's example is still broken and causes a coredump: struct Foo<T: ?Sized> {
x: u8,
y: T,
}
fn main() {
let foo: &Foo<[isize]> = &Foo { x: 1, y: [1, 2, 3] };
match *foo {
Foo { x, ref y } => {},
}
} @tomassedovic's example compiles fine even with #![feature(unboxed_closures)]
fn main() {
let i: isize = 0;
let some_closure = || {
let _capture = i;
};
} All of @hugwijst's variants now compile fine. |
I ran into this issue on the latest nightly with the following example:
If I change the first line to
It compiles fine. The error I get: |
@JustAPerson, I couldn't trigger an ICE with any of the code it this issue, but I found something interesting: as you said, this compiles fine: fn read_file(path : String) -> Box<[u8]> {
return Box::new([])
}
fn main() {
} But I think, it shouldn't. I've never seen return without a semicolon mentioned as valid Rust code. EDIT: I didn't find an open issue for this. If it's a bug, we should open a new one, but if it's a feature, it should be documented. |
Ok, it turned out to be valid syntax (#26425) and I still can't reproduce the ICE 👍 |
Thanks @pmarcelll! |
The bug is [1] and it ought to be fixed at some point. [1] rust-lang/rust#17257
rust version: rustc 0.12.0-pre-nightly (09abbbd 2014-09-11 00:05:41 +0000)
code to reproduce:
but this compiles fine
The text was updated successfully, but these errors were encountered: