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

ICE: const expr(8: &*"") of type &'static str has size 8 instead of 16 #22894

Closed
rprichard opened this issue Feb 28, 2015 · 6 comments
Closed
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@rprichard
Copy link
Contributor

Test case:

#[allow(dead_code)]
static X: &'static str = &*"";
fn main() {}

Output:

$ RUST_BACKTRACE=1 rustc test.rs  -O 
@ref8 = internal unnamed_addr constant %str_slice { i8* getelementptr inbounds ([0 x i8]* @str954, i32 0, i32 0), i64 0 }
{ i8*, i8* } undef
error: internal compiler error: const expr(8: &*"") 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>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:189

stack backtrace:
   1:         0x2c97f720 - sys::backtrace::write::h66f3f2784d0f6c5ddgA
   2:         0x2c9a7b80 - panicking::on_panic::h6fdde9e4e9166fe6jaJ
   3:         0x2c8e7c30 - rt::unwind::begin_unwind_inner::hba10c536ef2aae75MQI
   4:         0x29bf70c0 - rt::unwind::begin_unwind::h11287547919384241778
   5:         0x29bf7880 - diagnostic::Handler::bug::hcd811e06453c2215AHD
   6:         0x2a92f0e0 - session::Session::bug::h6899b8b34aff4289tjp
   7:         0x2b684c80 - trans::consts::const_expr::h035f67d1634baae2etn
   8:         0x2b5bdee0 - trans::base::get_item_val::h6996afac4f0d2cd8zdu
   9:         0x2b687ae0 - trans::consts::trans_static::h8a306b81be8d489c68n
  10:         0x2b5bbbf0 - trans::base::trans_item::h84b885e418e4a555QIt
  11:         0x2b6a49c0 - trans::base::trans_crate::h42b5704fc939dd15qEu
  12:         0x2d005970 - driver::phase_4_translate_to_llvm::h73df038fa8e4514eqNa
  13:         0x2cfdfec0 - driver::compile_input::h0de317319ab5c701Hba
  14:         0x2d0aae20 - run_compiler::hffa0c0711e361de8E5b
  15:         0x2d0a9720 - thunk::F.Invoke<A, R>::invoke::h12673221910893163557
  16:         0x2d0a8610 - rt::unwind::try::try_fn::h15130568597725528481
  17:         0x2ca13740 - rust_try_inner
  18:         0x2ca13730 - rust_try
  19:         0x2d0a8910 - thunk::F.Invoke<A, R>::invoke::h3924406537784056782
  20:         0x2c993990 - sys::thread::thread_start::h3734be2229bd3edegEE
  21:         0x268bb0c0 - start_thread
  22:         0x2c560449 - __clone
  23:                0x0 - <unknown>

Compiler version:

rustc 1.0.0-nightly (b47aebe3f 2015-02-26) (built 2015-02-27)
binary: rustc
commit-hash: b47aebe3fc2da06c760fd8ea19f84cbc41d34831
commit-date: 2015-02-26
build-date: 2015-02-27
host: x86_64-unknown-linux-gnu
release: 1.0.0-nightly

This issue has a similar error to that in #20074, but it's not clear to me that it's the same issue. The types involved are different, as are the mismatched size values. I'm also unable to reproduce that issue's failure -- maybe it's fixed already?

@dotdash
Copy link
Contributor

dotdash commented Feb 28, 2015

@eddyb is that related to your recent changes?

@dotdash dotdash added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Feb 28, 2015
@eddyb
Copy link
Member

eddyb commented Feb 28, 2015

@dotdash dereferencing &Unsized in constants never worked, but I made it show up outside the functions as well (giving @gankro some trouble).
The solution would be to make dereferencing &Unsized and referencing Unsized noops.

@frewsxcv
Copy link
Member

This is still an issue in Rust 1.0 beta2

~/Downloads $ rustc test.rs
@ref771 = internal unnamed_addr constant %str_slice { i8* getelementptr inbounds ([0 x i8]* @str770, i32 0, i32 0), i64 0 }
{ i8*, i8* } undef
error: internal compiler error: const expr(8: &*"") 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>', /Users/rustbuild/src/rust-buildbot/slave/beta-dist-rustc-mac/build/src/libsyntax/diagnostic.rs:209


~/Downloads $ rustc --version
rustc 1.0.0-beta.2 (e9080ec39 2015-04-16) (built 2015-04-16)

@bluss
Copy link
Member

bluss commented May 28, 2015

Still in nightly, same ICE

fn main() {
    (*"abc").len();
}

@kbknapp
Copy link

kbknapp commented Jan 21, 2016

I ran into this today as well, so still an issue in rustc 1.7.0-nightly (2bd875d3d 2016-01-19)

if "a" == &*"" {()}

@steveklabnik
Copy link
Member

This ICE seems to be fixed on

rustc 1.12.0-nightly (b30eff7ba 2016-08-05)

I have a hunch that this is due to MIR being turned on, though I'm not sure. Please let me know if this still ICEs for you, but closing for now 🎊

frewsxcv added a commit to frewsxcv/rust that referenced this issue Aug 8, 2016
Manishearth added a commit to Manishearth/rust that referenced this issue Aug 13, 2016
Manishearth added a commit to Manishearth/rust that referenced this issue Aug 13, 2016
eddyb added a commit to eddyb/rust that referenced this issue Aug 14, 2016
eddyb added a commit to eddyb/rust that referenced this issue Aug 14, 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

7 participants