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 const expression in array length #61368

Closed
varkor opened this issue May 30, 2019 · 9 comments
Closed

ICE with const expression in array length #61368

varkor opened this issue May 30, 2019 · 9 comments
Labels
A-const-generics Area: const generics (parameters and arguments) A-lazy-normalization Area: Lazy normalization (tracking issue: #60471) C-bug Category: This is a bug. F-const_generics `#![feature(const_generics)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@varkor
Copy link
Member

varkor commented May 30, 2019

#![feature(const_generics)]

struct Stack<const N: usize> {
    stack: [u64; N / 8],
}

fn main() {}

results in:

error: internal compiler error: constant in type had an ignored error
 --> src/main.rs:4:5
  |
4 |     stack: [u64; N / 8],
  |     ^^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:356:17
@varkor varkor added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-const-generics Area: const generics (parameters and arguments) labels May 30, 2019
@estebank
Copy link
Contributor

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=0d834551eb98a0fed48f2d5c654c2b58

error: internal compiler error: constant in type had an ignored error
 --> src/main.rs:7:5
  |
7 |     stack: MaybeUninit<[u64; N / 8]>
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:356:17
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/backtrace-0.3.25/src/backtrace/libunwind.rs:97
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/backtrace-0.3.25/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:47
   3: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:36
   4: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:197
   5: std::panicking::default_hook
             at src/libstd/panicking.rs:211
   6: rustc::util::common::panic_hook
   7: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:478
   8: std::panicking::begin_panic
   9: <rustc_errors::Handler as core::ops::drop::Drop>::drop
  10: core::ptr::real_drop_in_place
  11: core::ptr::real_drop_in_place
  12: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
  13: core::ptr::real_drop_in_place
  14: rustc_interface::interface::run_compiler_in_existing_thread_pool
  15: std::thread::local::LocalKey<T>::with
  16: scoped_tls::ScopedKey<T>::set
  17: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@varkor varkor changed the title ICE with repr(C) and const generics ICE with const expression in array length May 30, 2019
@jfrimmel
Copy link
Contributor

Also occurs with other math operations (i.e. it is not related to division only):

#![feature(const_generics)]

pub struct S<const N: usize>([u8; N*0]);

This produces:

error: internal compiler error: constant in type had an ignored error
 --> src/main.rs:3:30
  |
3 | pub struct S<const N: usize>([u8; N*0]);
  |                              ^^^^^^^^^

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:356:17

playground link

@vadixidav
Copy link
Contributor

Some code that also triggers this: playground link

@vadixidav
Copy link
Contributor

Just going to note that this is currently a blocker for implementing constant bit arrays (and probably, though I haven't checked, the storage for NxM matrices).

@varkor varkor added the A-lazy-normalization Area: Lazy normalization (tracking issue: #60471) label Jun 13, 2019
@eddyb
Copy link
Member

eddyb commented Jun 13, 2019

This is an instance of #43408, please use that as the canonical issue.

@Centril Centril added requires-nightly This issue requires a nightly compiler in some way. F-const_generics `#![feature(const_generics)]` labels Aug 6, 2019
@jonas-schievink jonas-schievink added the C-bug Category: This is a bug. label Aug 6, 2019
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Oct 15, 2019
@JohnTitor
Copy link
Member

It seems ICE has been fixed in latest nightly, could someone confirm it?

@lqd
Copy link
Member

lqd commented Jan 7, 2020

The snippet in the OP doesn't ICE on ef92009c1 2020-01-06.

@JohnTitor
Copy link
Member

Probably fixed by #67906, which has similar test case.

@varkor
Copy link
Member Author

varkor commented Jan 7, 2020

As the test case in #67906 was essentially the same as the original issue here, I don't think we need another one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) A-lazy-normalization Area: Lazy normalization (tracking issue: #60471) C-bug Category: This is a bug. F-const_generics `#![feature(const_generics)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

10 participants