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 with an associated constant as the length of a fixed-size array type of a static variable #25145

Closed
ghost opened this issue May 6, 2015 · 3 comments
Labels
E-needs-test Call for participation: Writing correctness tests. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@ghost
Copy link

ghost commented May 6, 2015

I tried this code:

#![feature(associated_consts)]

struct S;

impl S {
    const N: usize = 3;
}

static STUFF: [u8; S::N] = [0; S::N];

// NOTE: This works OK:
// static STUFF: [u8; 3] = [0; S::N];

fn main() {
    // NOTE: This works OK:
    // let stuff: [u8; S::N] = [0; S::N];
}

I get the error:

thread 'rustc' panicked at 'path not fully resolved: PathResolution { base_def: DefTy(DefId { krate: 0, node: 4 }, false), last_private: LastMod(AllPublic), depth: 1 }', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/librustc/middle/def.rs:81

Meta

rustc --version --verbose:
rustc 1.1.0-nightly (7bd7163 2015-05-06) (built 2015-05-05)
binary: rustc
commit-hash: 7bd7163
commit-date: 2015-05-06
build-date: 2015-05-05
host: x86_64-apple-darwin
release: 1.1.0-nightly

Stack backtrace:

   1:        0x10eb86f5f - sys::backtrace::write::hc8a4ac867687625dies
   2:        0x10eb8fa50 - panicking::on_panic::h8a20ee230368976dxuw
   3:        0x10eb49b45 - rt::unwind::begin_unwind_inner::hdec022e876757f01gcw
   4:        0x10eb4a96c - rt::unwind::begin_unwind_fmt::h6ffe61c334a81630mbw
   5:        0x10bd00e38 - middle::const_eval::eval_const_expr_partial::h814207524cef7390Tii
   6:        0x10b9c0aed - astconv::ast_ty_to_ty::h9119a591013371dfrSv
   7:        0x10ba41933 - collect::type_scheme_of_item::h3901b884cf3c707cdny
   8:        0x10ba39a2c - collect::convert_typed_item::h12a84069945ba57eQry
   9:        0x10ba211ad - collect::convert_item::hcb1eaa0733f02657eBx
  10:        0x10ba67b56 - check_crate::closure.38613
  11:        0x10ba65ada - check_crate::h71ec2befa9b49c1f5CC
  12:        0x10b2cff27 - driver::phase_3_run_analysis_passes::hcfdd4de2213fe030tGa
  13:        0x10b2b1c2c - driver::compile_input::h93cb3a50ed1b3f97Qba
  14:        0x10b370c93 - run_compiler::h7ca7d41460963b3165b
  15:        0x10b36e3fa - boxed::F.FnBox<A>::call_box::h5883147459539851824
  16:        0x10b36d957 - rt::unwind::try::try_fn::h498179752253104642
  17:        0x10ec12028 - rust_try_inner
  18:        0x10ec12015 - rust_try
  19:        0x10b36dc2d - boxed::F.FnBox<A>::call_box::h5554344682679983399
  20:        0x10eb8e44d - sys::thread::Thread::new::thread_start::h71342e3350e45779fxv
  21:     0x7fff921d0267 - _pthread_body
  22:     0x7fff921d01e4 - _pthread_start
@quantheory
Copy link
Contributor

Although it's probably not obvious from the thread there, I'm 99.9% confident that this is ultimately the same as #24938.

@apasel422
Copy link
Contributor

This no longer ICEs and instead errors:

foo.rs:9:20: 9:24 error: array length constant evaluation error: unresolved path in constant expression [E0250]
foo.rs:9 static STUFF: [u8; S::N] = [0; S::N];
                            ^~~~

@alexcrichton alexcrichton added the E-needs-test Call for participation: Writing correctness tests. label Oct 24, 2015
@apasel422 apasel422 mentioned this issue Oct 25, 2015
bors added a commit that referenced this issue Oct 25, 2015
Closes #22781.
Closes #23891.
Closes #24956.
Closes #25145.
Closes #25693.
Closes #26095.
Closes #26459.
Closes #27320.
Closes #27895.
@vks
Copy link
Contributor

vks commented Oct 26, 2015

So this is not supposed to work?

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: Writing correctness tests. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

5 participants