Skip to content

ICE: Size != Size #127219

Closed
Closed

Description

snippet:

const FOO: &str = unsafe { &*(1_usize as *const [i64; 0] as *const [u8] as *const str) };

Version information

rustc 1.81.0-nightly (221e2741c 2024-07-01)
binary: rustc
commit-hash: 221e2741c39515a5de6da42d8c76ee1e132c2c74
commit-date: 2024-07-01
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.tY2IsWZigJvc/rustc_testrunner_tmpdir_reporting.t3rMboN5RF2v/mvce.rs:1:90
  |
1 | const FOO: &str = unsafe { &*(1_usize as *const [i64; 0] as *const [u8] as *const str) };
  |                                                                                          ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.tY2IsWZigJvc/rustc_testrunner_tmpdir_reporting.t3rMboN5RF2v/mvce.rs`

error[E0607]: cannot cast thin pointer `*const [i64; 0]` to fat pointer `*const [u8]`
 --> /tmp/icemaker_global_tempdir.tY2IsWZigJvc/rustc_testrunner_tmpdir_reporting.t3rMboN5RF2v/mvce.rs:1:31
  |
1 | const FOO: &str = unsafe { &*(1_usize as *const [i64; 0] as *const [u8] as *const str) };
  |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at compiler/rustc_const_eval/src/interpret/cast.rs:212:13:
assertion `left == right` failed
  left: Size(8 bytes)
 right: Size(16 bytes)
stack backtrace:
   0:     0x7442b00f13d5 - std::backtrace_rs::backtrace::libunwind::trace::hb712d1033083f19f
                               at /rustc/221e2741c39515a5de6da42d8c76ee1e132c2c74/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x7442b00f13d5 - std::backtrace_rs::backtrace::trace_unsynchronized::hcd45231d964c5f87
                               at /rustc/221e2741c39515a5de6da42d8c76ee1e132c2c74/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7442b00f13d5 - std::sys::backtrace::_print_fmt::ha326387fd7186899
                               at /rustc/221e2741c39515a5de6da42d8c76ee1e132c2c74/library/std/src/sys/backtrace.rs:68:5
   3:     0x7442b00f13d5 - <std::sys::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb0a71f126ecc5f94
                               at /rustc/221e2741c39515a5de6da42d8c76ee1e132c2c74/library/std/src/sys/backtrace.rs:44:22
   4:     0x7442b0140adb - core::fmt::rt::Argument::fmt::hcb80cd58ae514c57
                               at /rustc/221e2741c39515a5de6da42d8c76ee1e132c2c74/library/core/src/fmt/rt.rs:173:76
   5:     0x7442b0140adb - core::fmt::write::h24e86a79a1d9fd27
                               at /rustc/221e2741c39515a5de6da42d8c76ee1e132c2c74/library/core/src/fmt/mod.rs:1174:21
   6:     0x7442b00e5f7f - std::io::Write::write_fmt::h6f24f5499b917dd0
                               at /rustc/221e2741c39515a5de6da42d8c76ee1e132c2c74/library/std/src/io/mod.rs:1835:15
   7:     0x7442b00f11ae - std::sys::backtrace::_print::hab3688cd990b4da1
                               at /rustc/221e2741c39515a5de6da42d8c76ee1e132c2c74/library/std/src/sys/backtrace.rs:47:5
   8:     0x7442b00f11ae - std::sys::backtrace::print::hd7ca970b8f6f0d2a
                               at /rustc/221e2741c39515a5de6da42d8c76ee1e132c2c74/library/std/src/sys/backtrace.rs:34:9
   9:     0x7442b00f3af9 - std::panicking::default_hook::{{closure}}::hbcefa19962d38670
  10:     0x7442b00f389c - std::panicking::default_hook::ha30d3ad58a1508fe
                               at /rustc/221e2741c39515a5de6da42d8c76ee1e132c2c74/library/std/src/panicking.rs:292:9
  11:     0x7442ac5f21d9 - std[a32dded7438b921f]::panicking::update_hook::<alloc[e66b80bbeb26e33f]::boxed::Box<rustc_driver_impl[caf9fb610f137d76]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7442b00f441f - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h62bf5bbfe5d978e7
                               at /rustc/221e2741c39515a5de6da42d8c76ee1e132c2c74/library/alloc/src/boxed.rs:2078:9
  13:     0x7442b00f441f - std::panicking::rust_panic_with_hook::h27b2c56b49aaf9e9
                               at /rustc/221e2741c39515a5de6da42d8c76ee1e132c2c74/library/std/src/panicking.rs:804:13
  14:     0x7442b00f4047 - std::panicking::begin_panic_handler::{{closure}}::h5289f8126ff30957
                               at /rustc/221e2741c39515a5de6da42d8c76ee1e132c2c74/library/std/src/panicking.rs:670:13
  15:     0x7442b00f1899 - std::sys::backtrace::__rust_end_short_backtrace::h21cd56c9f55744b2
                               at /rustc/221e2741c39515a5de6da42d8c76ee1e132c2c74/library/std/src/sys/backtrace.rs:171:18
  16:     0x7442b00f3cd4 - rust_begin_unwind
                               at /rustc/221e2741c39515a5de6da42d8c76ee1e132c2c74/library/std/src/panicking.rs:661:5
  17:     0x7442b013d093 - core::panicking::panic_fmt::h37d5e7cdc93b0dc7
                               at /rustc/221e2741c39515a5de6da42d8c76ee1e132c2c74/library/core/src/panicking.rs:74:14
  18:     0x7442b013d59e - core::panicking::assert_failed_inner::h6c69218920a45b99
                               at /rustc/221e2741c39515a5de6da42d8c76ee1e132c2c74/library/core/src/panicking.rs:410:17
  19:     0x7442ac55ccf3 - core[a1d5b26218b7595a]::panicking::assert_failed::<rustc_abi[63f89227b92ff6eb]::Size, rustc_abi[63f89227b92ff6eb]::Size>
  20:     0x7442ae860466 - <rustc_const_eval[5026d74ad8aa4e4c]::interpret::eval_context::InterpCx<rustc_const_eval[5026d74ad8aa4e4c]::const_eval::machine::CompileTimeMachine>>::eval_rvalue_into_place
  21:     0x7442ae7c1dcc - rustc_const_eval[5026d74ad8aa4e4c]::const_eval::eval_queries::eval_to_allocation_raw_provider
  22:     0x7442ae7c11b6 - rustc_query_impl[823e173f31dca1d9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[823e173f31dca1d9]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9e476e531f4cdc39]::query::erase::Erased<[u8; 24usize]>>
  23:     0x7442ae7baf91 - rustc_query_system[837d787005d5746e]::query::plumbing::try_execute_query::<rustc_query_impl[823e173f31dca1d9]::DynamicConfig<rustc_query_system[837d787005d5746e]::query::caches::DefaultCache<rustc_middle[9e476e531f4cdc39]::ty::ParamEnvAnd<rustc_middle[9e476e531f4cdc39]::mir::interpret::GlobalId>, rustc_middle[9e476e531f4cdc39]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[823e173f31dca1d9]::plumbing::QueryCtxt, false>
  24:     0x7442ae7bab70 - rustc_query_impl[823e173f31dca1d9]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
  25:     0x7442ae7bcdde - rustc_const_eval[5026d74ad8aa4e4c]::const_eval::eval_queries::eval_to_const_value_raw_provider
  26:     0x7442ae7bcbf6 - rustc_query_impl[823e173f31dca1d9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[823e173f31dca1d9]::query_impl::eval_to_const_value_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9e476e531f4cdc39]::query::erase::Erased<[u8; 24usize]>>
  27:     0x7442ae7baf54 - rustc_query_system[837d787005d5746e]::query::plumbing::try_execute_query::<rustc_query_impl[823e173f31dca1d9]::DynamicConfig<rustc_query_system[837d787005d5746e]::query::caches::DefaultCache<rustc_middle[9e476e531f4cdc39]::ty::ParamEnvAnd<rustc_middle[9e476e531f4cdc39]::mir::interpret::GlobalId>, rustc_middle[9e476e531f4cdc39]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[823e173f31dca1d9]::plumbing::QueryCtxt, false>
  28:     0x7442ae7baa70 - rustc_query_impl[823e173f31dca1d9]::query_impl::eval_to_const_value_raw::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7442adeffdf6 - <rustc_middle[9e476e531f4cdc39]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[131fe9ac51ca670c]::check_crate::{closure#3}>::{closure#0}
  30:     0x7442adefd594 - rustc_hir_analysis[131fe9ac51ca670c]::check_crate
  31:     0x7442adef3215 - rustc_interface[b2c362fcb0f0a28c]::passes::analysis
  32:     0x7442adef2ddb - rustc_query_impl[823e173f31dca1d9]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[823e173f31dca1d9]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9e476e531f4cdc39]::query::erase::Erased<[u8; 1usize]>>
  33:     0x7442aeadcce5 - rustc_query_system[837d787005d5746e]::query::plumbing::try_execute_query::<rustc_query_impl[823e173f31dca1d9]::DynamicConfig<rustc_query_system[837d787005d5746e]::query::caches::SingleCache<rustc_middle[9e476e531f4cdc39]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[823e173f31dca1d9]::plumbing::QueryCtxt, false>
  34:     0x7442aeadca4f - rustc_query_impl[823e173f31dca1d9]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7442aea1c407 - rustc_interface[b2c362fcb0f0a28c]::interface::run_compiler::<core[a1d5b26218b7595a]::result::Result<(), rustc_span[5b114e5127e2dfa0]::ErrorGuaranteed>, rustc_driver_impl[caf9fb610f137d76]::run_compiler::{closure#0}>::{closure#1}
  36:     0x7442ae99c689 - std[a32dded7438b921f]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[b2c362fcb0f0a28c]::util::run_in_thread_with_globals<rustc_interface[b2c362fcb0f0a28c]::util::run_in_thread_pool_with_globals<rustc_interface[b2c362fcb0f0a28c]::interface::run_compiler<core[a1d5b26218b7595a]::result::Result<(), rustc_span[5b114e5127e2dfa0]::ErrorGuaranteed>, rustc_driver_impl[caf9fb610f137d76]::run_compiler::{closure#0}>::{closure#1}, core[a1d5b26218b7595a]::result::Result<(), rustc_span[5b114e5127e2dfa0]::ErrorGuaranteed>>::{closure#0}, core[a1d5b26218b7595a]::result::Result<(), rustc_span[5b114e5127e2dfa0]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a1d5b26218b7595a]::result::Result<(), rustc_span[5b114e5127e2dfa0]::ErrorGuaranteed>>
  37:     0x7442ae99c43a - <<std[a32dded7438b921f]::thread::Builder>::spawn_unchecked_<rustc_interface[b2c362fcb0f0a28c]::util::run_in_thread_with_globals<rustc_interface[b2c362fcb0f0a28c]::util::run_in_thread_pool_with_globals<rustc_interface[b2c362fcb0f0a28c]::interface::run_compiler<core[a1d5b26218b7595a]::result::Result<(), rustc_span[5b114e5127e2dfa0]::ErrorGuaranteed>, rustc_driver_impl[caf9fb610f137d76]::run_compiler::{closure#0}>::{closure#1}, core[a1d5b26218b7595a]::result::Result<(), rustc_span[5b114e5127e2dfa0]::ErrorGuaranteed>>::{closure#0}, core[a1d5b26218b7595a]::result::Result<(), rustc_span[5b114e5127e2dfa0]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a1d5b26218b7595a]::result::Result<(), rustc_span[5b114e5127e2dfa0]::ErrorGuaranteed>>::{closure#2} as core[a1d5b26218b7595a]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x7442b00fe27b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8a74f28960a176f3
                               at /rustc/221e2741c39515a5de6da42d8c76ee1e132c2c74/library/alloc/src/boxed.rs:2064:9
  39:     0x7442b00fe27b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3f01a028499c33ae
                               at /rustc/221e2741c39515a5de6da42d8c76ee1e132c2c74/library/alloc/src/boxed.rs:2064:9
  40:     0x7442b00fe27b - std::sys::pal::unix::thread::Thread::new::thread_start::h256c3a78891e662c
                               at /rustc/221e2741c39515a5de6da42d8c76ee1e132c2c74/library/std/src/sys/pal/unix/thread.rs:108:17
  41:     0x7442a90a6ded - <unknown>
  42:     0x7442a912a0dc - <unknown>
  43:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: rustc 1.81.0-nightly (221e2741c 2024-07-01) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `FOO`
#1 [eval_to_const_value_raw] simplifying constant for the type system `FOO`
end of query stack
error: aborting due to 2 previous errors

Some errors have detailed explanations: E0601, E0607.
For more information about an error, try `rustc --explain E0601`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions