Skip to content

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

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

Closed
dark0ne opened this issue May 8, 2018 · 1 comment
Closed

Comments

@dark0ne
Copy link

dark0ne commented May 8, 2018

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

@oli-obk
Copy link
Contributor

oli-obk commented May 8, 2018

This is another symptom of #49955

You can work around it by using &(&FOO)[bar]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants