Skip to content

Rustc can't check constness of foreign globals #9866

Closed
@LeoTestard

Description

@LeoTestard

The following code cause Rustc to fail:

extern
{
    static foo: u64;
}

static bar: u64 = foo;

fn main()
{
}

With the following message :

task '<unnamed>' failed at 'const not bound to an item', /Users/leo/Downloads/rust/src/librustc/middle/check_const.rs:269
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', /Users/leo/Downloads/rust/src/librustc/rustc.rs:391

Shouldn't Rustc be able to compile this code ? Since the foreign global is static, it should be possible to use it in constant expressions, juste like any static declared in Rust code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions