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

Compiler panic: type &'static str has size 8 instead of 16 #36236

Closed
rwestlund opened this issue Sep 3, 2016 · 1 comment
Closed

Compiler panic: type &'static str has size 8 instead of 16 #36236

rwestlund opened this issue Sep 3, 2016 · 1 comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@rwestlund
Copy link

rwestlund commented Sep 3, 2016

The compiler panics when the following standalone code is built:

use std::str;
fn main () {
    const filename: &'static str = "myfile";
    format!("File {} not found.", &*filename);
}

Here's the output of cargo build:

   Compiling test v0.0.1 (file:///usr/home/randy/code/test)
src/main.rs:4:5: 4:45 warning: constant `filename` should have an upper case name such as `FILENAME`, #[warn(non_upper_case_globals)] on by default
src/main.rs:4     const filename: &'static str = "myfile";
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@const3845 = internal unnamed_addr constant %str_slice { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str3844, i32 0, i32 0), i64 6 }, align 8
{ i8*, i64 } undef
error: internal compiler error: src/librustc_trans/consts.rs:443: const expr(38: &*filename) of type &'static str has size 8 instead of 16
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', src/libsyntax/errors/mod.rs:575

Both the lowercase constant and the curly braces in the string are necessary to reproduce the panic.

Rust version:

rustc 1.9.0
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-freebsd
release: 1.9.0
@TimNN
Copy link
Contributor

TimNN commented Sep 3, 2016

This is fixed on beta (and looks like a duplicate of #30386).

@apasel422 apasel422 added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Sep 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants