Skip to content

ICE when a static variable is declared of type for which the Drop trait is implemented #9243

Closed
@MarkJr94

Description

@MarkJr94

Minimal test case:

struct Test {
    mem: int,
}

pub static g_test: Test = Test {
    mem: 0,
};

impl Drop for Test {
    fn drop(&self) {
    }
}

fn main() {

}

Resulting Error after run with RUST_LOG=rustc=1 rustc test.rs:

task <unnamed> failed at 'assertion failed: `(left == right) && (right == left)` (left: `1u`, right: `2u`)', /build/buildd/rust-nightly-201309160805~3fbfab0~raring/src/librustc/middle/trans/adt.rs:545
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1 to get further details and report the results to github.com/mozilla/rust/issues
task <unnamed> failed at 'explicit failure', /build/buildd/rust-nightly-201309160805~3fbfab0~raring/src/librustc/rustc.rs:377

Also, this:

struct Test;

pub static g_test: Test = Test;

impl Drop for Test {
    fn drop(&self) {
    }
}

fn main() {

}

compiles just fine, although I believe both cases should give a compilation error about having static variable implementing the Drop trait.

My rustc is acquired form the rust-nightly package in the Ubuntu repo.

Output of rustc --version:

rustc 0.8-pre
host: x86_64-unknown-linux-gnu

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priority

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions