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

LLVM assertion error for #[deriving(PartialEq)] on an unsized type #18805

Closed
SimonSapin opened this issue Nov 9, 2014 · 8 comments
Closed

LLVM assertion error for #[deriving(PartialEq)] on an unsized type #18805

SimonSapin opened this issue Nov 9, 2014 · 8 comments
Labels
A-DSTs Area: Dynamically-sized types (DSTs) E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@SimonSapin
Copy link
Contributor

Test case:

#[deriving(PartialEq)]
pub struct Wtf8Slice {
    bytes: [u8]
}

Output of rustc nigthly 45cbdec 2014-11-07:

rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/llvm/lib/IR/Instructions.cpp:1086: void llvm::StoreInst::AssertOK(): Assertion `getOperand(0)->getType() == cast<PointerType>(getOperand(1)->getType())->getElementType() && "Ptr must be a pointer to Val type!"' failed.
@huonw huonw added the A-DSTs Area: Dynamically-sized types (DSTs) label Nov 9, 2014
@SimonSapin
Copy link
Contributor Author

Output of rustc --pretty expanded:

#![feature(phase)]
#![no_std]
#![feature(globs)]
#[phase(plugin, link)]
extern crate "std" as std;
extern crate "native" as rt;
#[prelude_import]
use std::prelude::*;
pub struct Wtf8Slice {
    bytes: [u8],
}
#[automatically_derived]
impl ::std::cmp::PartialEq for Wtf8Slice {
    #[inline]
    fn eq(&self, __arg_0: &Wtf8Slice) -> ::bool {
        match *__arg_0 {
            Wtf8Slice { bytes: ref __self_1_0 } =>
            match *self {
                Wtf8Slice { bytes: ref __self_0_0 } =>
                true && (*__self_0_0) == (*__self_1_0),
            },
        }
    }
    #[inline]
    fn ne(&self, __arg_0: &Wtf8Slice) -> ::bool {
        match *__arg_0 {
            Wtf8Slice { bytes: ref __self_1_0 } =>
            match *self {
                Wtf8Slice { bytes: ref __self_0_0 } =>
                false || (*__self_0_0) != (*__self_1_0),
            },
        }
    }
}

@huonw huonw added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Nov 9, 2014
@apasel422
Copy link
Contributor

A similar problem, with a different error:

struct Foo {
    bytes: [u8],
}

fn bar(&Foo { ref bytes }: &Foo) {}

Output of rustc 0.13.0-nightly (770378a31 2014-11-20 23:02:01 +0000):

rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/llvm/include/llvm/Support/Casting.h:237: typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = llvm::PointerType; Y = const llvm::Type; typename llvm::cast_retty<X, Y*>::ret_type = const llvm::PointerType*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.

This also applies to tuple structs with an unsized field.

@japaric
Copy link
Member

japaric commented Nov 22, 2014

@apasel422 That looks like #19064

@steveklabnik
Copy link
Member

This still ICEs for me.

@XMPPwocky
Copy link
Contributor

It still ICEs. Looks like the core issue is trying to store a %struct.Wtf8Slice** in an alloca for {i8*, i64} .

@tamird
Copy link
Contributor

tamird commented Apr 21, 2015

This is now a segfault:

#![crate_type="lib"]

#[derive(PartialEq)]
pub struct Wtf8Slice {
    bytes: [u8]
}
$ rustc main.rs
Segmentation fault: 11

@steveklabnik steveklabnik added I-wrong and removed I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Apr 22, 2015
@arielb1
Copy link
Contributor

arielb1 commented Sep 13, 2015

Does not seem to be an issue on 1.2+

@arielb1 arielb1 added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Sep 13, 2015
@SimonSapin
Copy link
Contributor Author

Indeed, I can’t reproduce this anymore.

lnicola pushed a commit to lnicola/rust that referenced this issue Jan 7, 2025
internal: Implement `<RaSpanServer as SourceFile>::eq`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-DSTs Area: Dynamically-sized types (DSTs) E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

No branches or pull requests

8 participants