Skip to content

Reference to a static object within const fn leads to compiler panic. #50529

Closed
@dark0ne

Description

@dark0ne

I am initializing a reference to an object with static lifetime within a const function and the compiler panics.
I reduced the code to the following example:

https://play.rust-lang.org/?gist=2581bfb95f9f8e3f306bee0862f9f415&version=nightly&mode=debug

I get the compiler output:

error: internal compiler error: librustc_mir/monomorphize/collector.rs:1162: alloc id without corresponding allocation: 7

thread 'main' panicked at 'Box', librustc_errors/lib.rs:554:9
note: Run with RUST_BACKTRACE=1 for a backtrace.
error: aborting due to previous error

note: the compiler unexpectedly panicked. this is a bug.

note: rustc 1.27.0-nightly (565235e 2018-05-07) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type bin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions