Skip to content

ICE when taking reference of an array element across crate border #13077

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
rsaarelm opened this issue Mar 22, 2014 · 3 comments
Closed

ICE when taking reference of an array element across crate border #13077

rsaarelm opened this issue Mar 22, 2014 · 3 comments
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@rsaarelm
Copy link

Script to reproduce:

#!/bin/sh

cat > array.rs <<EOF
pub static ARRAY: &'static [int] = &[1];
EOF

cat > main.rs <<EOF
extern crate array;
use array::ARRAY;
static X: &'static int = &ARRAY[0];
pub fn main() {}
EOF

rustc --version
rustc array.rs --crate-type rlib
RUST_BACKTRACE=1 rustc main.rs -L .

Version:

rustc 0.10-pre (092afdb 2014-03-22 00:56:47 -0700)
host: x86_64-unknown-linux-gnu

Output:

task 'rustc' failed at 'expected item, found unknown node (id=3)', /home/rsaarelm/local/rust/src/libsyntax/ast_map.rs:256
stack backtrace:
   1:     0x7fa9ece4c150 - rt::backtrace::imp::write::h65d4519594096df0zFb::v0.10.pre
   2:     0x7fa9ecdb1b20 - rt::unwind::begin_unwind_inner::h76e51d0b3f21ae573fb::v0.10.pre
   3:     0x7fa9ecdb17a0 - rt::unwind::begin_unwind_fmt::hcb4030a35e75e94bdfb::v0.10.pre
   4:     0x7fa9ebeecab0 - ast_map::Map::expect_item::h926341365065e5c2yWs::v0.10.pre
   5:     0x7fa9ed897ff0 - middle::trans::consts::get_const_val::hf35e5dbbcbb0c325gTi::v0.10.pre
   6:     0x7fa9ed898c80 - middle::trans::consts::const_expr_unadjusted::h8aa95ecf95053fc9wbj::v0.10.pre
   7:     0x7fa9ed8967f0 - middle::trans::consts::const_expr::h30ccf7f1ea2db6bb3Ui::v0.10.pre
   8:     0x7fa9ed898c80 - middle::trans::consts::const_expr_unadjusted::h8aa95ecf95053fc9wbj::v0.10.pre
   9:     0x7fa9ed8967f0 - middle::trans::consts::const_expr::h30ccf7f1ea2db6bb3Ui::v0.10.pre
  10:     0x7fa9ed898c80 - middle::trans::consts::const_expr_unadjusted::h8aa95ecf95053fc9wbj::v0.10.pre
  11:     0x7fa9ed8967f0 - middle::trans::consts::const_expr::h30ccf7f1ea2db6bb3Ui::v0.10.pre
  12:     0x7fa9ed7f2730 - middle::trans::base::get_item_val::h6d0d4cb5e1eec3caH9o::v0.10.pre
  13:     0x7fa9ed898660 - middle::trans::consts::trans_const::ha5c66b533e4b5e01rJj::v0.10.pre
  14:     0x7fa9ed7f1510 - middle::trans::base::trans_item::haefb1368e3f72c06EPo::v0.10.pre
  15:     0x7fa9ed8cb160 - middle::trans::base::trans_mod::h443add462d5f45c2PUo::v0.10.pre
  16:     0x7fa9ed8d4dd0 - middle::trans::base::trans_crate::hb821fec7a7227b18Jvq::v0.10.pre
  17:     0x7fa9edf0fcf0 - driver::driver::phase_4_translate_to_llvm::hd60d08bb19ab14c3ncf::v0.10.pre
  18:     0x7fa9edf11ec0 - driver::driver::compile_input::hea07fdb06f747ebclsf::v0.10.pre
  19:     0x7fa9edf359a0 - run_compiler::hb633d4f48873b5b685m::v0.10.pre
  20:     0x7fa9edf48c40 - main_args::closure.90956
  21:     0x7fa9edf47570 - monitor::closure.90841
  22:     0x7fa9edf42f40 - task::TaskBuilder::try::closure.90652
  23:     0x7fa9efc982c0 - task::spawn_opts::closure.7490
  24:     0x7fa9ece47870 - rt::task::Task::run::closure.40702
  25:     0x7fa9ece52c30 - rust_try
  26:     0x7fa9ece476b0 - rt::task::Task::run::hbf611f12dab23ee8848::v0.10.pre
  27:     0x7fa9efc98060 - task::spawn_opts::closure.7463
  28:     0x7fa9ece4ac10 - rt::thread::thread_start::h1eaa8730822d5e53AL9::v0.10.pre
  29:     0x7fa9ea1f8fe0 - start_thread
  30:     0x7fa9eca7cce9 - clone
  31:                0x0 - <unknown>
@emberian emberian changed the title Internal compiler error when taking reference of an array element across crate border ICE when taking reference of an array element across crate border Mar 22, 2014
@emberian emberian added the I-ICE label Mar 22, 2014
@emberian
Copy link
Member

cc @alexcrichton

@Twisol
Copy link

Twisol commented Jan 4, 2015

This particular example no longer causes an ICE.

$ rustc main.rs -L .
main.rs:3:27: 3:35 error: cannot refer to the interior of another static, use a constant instead
main.rs:3 static X: &'static int = &ARRAY[0];
                                    ^~~~~~~~
error: aborting due to previous error
$ rustc --verbose --version
rustc 0.13.0-nightly (c6c786671 2015-01-04 00:50:59 +0000)
binary: rustc
commit-hash: c6c786671d692d7b13c2e5c68a53001327b4b125
commit-date: 2015-01-04 00:50:59 +0000
host: x86_64-apple-darwin
release: 0.13.0-nightly

@sfackler sfackler added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jan 5, 2015
@steveklabnik
Copy link
Member

Can confirm, no more ICE.

@steveklabnik steveklabnik removed the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jan 16, 2015
@bors bors closed this as completed in c1f6951 Mar 17, 2015
flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 25, 2024
…r=Alexendoo

Fix `needless_option_as_deref` false-positive on struct literals

changelog: [`needless_option_as_deref`] Fix false-positive on struct literals.

Fixes rust-lang#13077 .

r?  Alexendoo
flip1995 pushed a commit to flip1995/rust that referenced this issue Feb 20, 2025
fixes rust-lang#14148

Another case of rust-lang#13077 and rust-lang#8646

changelog: [`needless_option_as_deref`]: fix FP in trait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

No branches or pull requests

5 participants