Closed as duplicate of#130970
Description
Code
fn main() {
extern "C" {
static symbol: [usize];
}
println!("{}", symbol[0]);
}
Affected release channels
- Previous Stable
- Current Stable
- Current Beta
- Current Nightly
Rust Version
$ rustc --version --verbose
rustc 1.85.0-nightly (7f75bfa1a 2024-12-30)
binary: rustc
commit-hash: 7f75bfa1ad4e9a9d33a179a90603001515e91991
commit-date: 2024-12-30
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.6
Current error output
Backtrace
$ rustc test.rs
error[E0277]: the size for values of type `[usize]` cannot be known at compilation time
--> test.rs:3:20
|
3 | static symbol: [usize];
| ^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[usize]`
error[E0133]: use of extern static is unsafe and requires unsafe function or block
--> test.rs:5:18
|
5 | println!("{}", symbol[0]);
| ^^^^^^ use of extern static
|
= note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
error: internal compiler error: /rustc/7f75bfa1ad4e9a9d33a179a90603001515e91991/compiler/rustc_const_eval/src/interpret/operand.rs:661:13: primitive read not possible for type: ()
--> test.rs:1:1
|
1 | fn main() {
| ^^^^^^^^^
thread 'rustc' panicked at /rustc/7f75bfa1ad4e9a9d33a179a90603001515e91991/compiler/rustc_const_eval/src/interpret/operand.rs:661:13:
Box<dyn Any>
stack backtrace:
0: 0x7f5f248e6cea - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hfeb90fd9b5398c4f
1: 0x7f5f2502d466 - core::fmt::write::hd020802d4198e71b
2: 0x7f5f25f34bd1 - std::io::Write::write_fmt::h7e2e8e4cf92a8d65
3: 0x7f5f248e6b42 - std::sys::backtrace::BacktraceLock::print::h66b4c03e5039d072
4: 0x7f5f248e9049 - std::panicking::default_hook::{{closure}}::hcc157a01562efcba
5: 0x7f5f248e8e92 - std::panicking::default_hook::h21db3d7d04627650
6: 0x7f5f23a54688 - std[cb5a7f0ea0430aa5]::panicking::update_hook::<alloc[dd9cf49c51639ce8]::boxed::Box<rustc_driver_impl[a708e1f659847ef0]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7f5f248e9803 - std::panicking::rust_panic_with_hook::h6f76ca5eeec77396
8: 0x7f5f23a8c941 - std[cb5a7f0ea0430aa5]::panicking::begin_panic::<rustc_errors[d62dd508640af3db]::ExplicitBug>::{closure#0}
9: 0x7f5f23a81b26 - std[cb5a7f0ea0430aa5]::sys::backtrace::__rust_end_short_backtrace::<std[cb5a7f0ea0430aa5]::panicking::begin_panic<rustc_errors[d62dd508640af3db]::ExplicitBug>::{closure#0}, !>
10: 0x7f5f23a818df - std[cb5a7f0ea0430aa5]::panicking::begin_panic::<rustc_errors[d62dd508640af3db]::ExplicitBug>
11: 0x7f5f23a968a1 - <rustc_errors[d62dd508640af3db]::diagnostic::BugAbort as rustc_errors[d62dd508640af3db]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
12: 0x7f5f23ff172c - <rustc_errors[d62dd508640af3db]::DiagCtxtHandle>::span_bug::<rustc_span[18838cea79d79020]::span_encoding::Span, alloc[dd9cf49c51639ce8]::string::String>
13: 0x7f5f240766d7 - rustc_middle[2bb6193700b5c8f1]::util::bug::opt_span_bug_fmt::<rustc_span[18838cea79d79020]::span_encoding::Span>::{closure#0}
14: 0x7f5f2405b77a - rustc_middle[2bb6193700b5c8f1]::ty::context::tls::with_opt::<rustc_middle[2bb6193700b5c8f1]::util::bug::opt_span_bug_fmt<rustc_span[18838cea79d79020]::span_encoding::Span>::{closure#0}, !>::{closure#0}
15: 0x7f5f2405b60b - rustc_middle[2bb6193700b5c8f1]::ty::context::tls::with_context_opt::<rustc_middle[2bb6193700b5c8f1]::ty::context::tls::with_opt<rustc_middle[2bb6193700b5c8f1]::util::bug::opt_span_bug_fmt<rustc_span[18838cea79d79020]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
16: 0x7f5f2249b887 - rustc_middle[2bb6193700b5c8f1]::util::bug::span_bug_fmt::<rustc_span[18838cea79d79020]::span_encoding::Span>
17: 0x7f5f22149b2d - <rustc_mir_transform[81e1da8f8da037e0]::known_panics_lint::ConstPropagator as rustc_middle[2bb6193700b5c8f1]::mir::visit::Visitor>::visit_assign
18: 0x7f5f221416ab - <rustc_mir_transform[81e1da8f8da037e0]::known_panics_lint::ConstPropagator as rustc_middle[2bb6193700b5c8f1]::mir::visit::Visitor>::visit_body
19: 0x7f5f25e2f4e5 - <rustc_mir_transform[81e1da8f8da037e0]::known_panics_lint::KnownPanicsLint as rustc_mir_transform[81e1da8f8da037e0]::pass_manager::MirLint>::run_lint
20: 0x7f5f25023a17 - rustc_mir_transform[81e1da8f8da037e0]::run_analysis_to_runtime_passes
21: 0x7f5f22813a8a - rustc_mir_transform[81e1da8f8da037e0]::mir_drops_elaborated_and_const_checked
22: 0x7f5f252fdeb7 - rustc_query_impl[bdc2370c3287c759]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[bdc2370c3287c759]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[2bb6193700b5c8f1]::query::erase::Erased<[u8; 8usize]>>
23: 0x7f5f252fe20e - rustc_query_system[7637a88347177bdb]::query::plumbing::try_execute_query::<rustc_query_impl[bdc2370c3287c759]::DynamicConfig<rustc_data_structures[10c3d719be6321bd]::vec_cache::VecCache<rustc_span[18838cea79d79020]::def_id::LocalDefId, rustc_middle[2bb6193700b5c8f1]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[7637a88347177bdb]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[bdc2370c3287c759]::plumbing::QueryCtxt, false>
24: 0x7f5f252fdc67 - rustc_query_impl[bdc2370c3287c759]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
25: 0x7f5f25461731 - rustc_interface[5a45d25d69207022]::passes::run_required_analyses
26: 0x7f5f25f48d5e - rustc_interface[5a45d25d69207022]::passes::analysis
27: 0x7f5f25f48d2f - rustc_query_impl[bdc2370c3287c759]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[bdc2370c3287c759]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[2bb6193700b5c8f1]::query::erase::Erased<[u8; 0usize]>>
28: 0x7f5f25f94cd5 - rustc_query_system[7637a88347177bdb]::query::plumbing::try_execute_query::<rustc_query_impl[bdc2370c3287c759]::DynamicConfig<rustc_query_system[7637a88347177bdb]::query::caches::SingleCache<rustc_middle[2bb6193700b5c8f1]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[bdc2370c3287c759]::plumbing::QueryCtxt, false>
29: 0x7f5f25f94a0e - rustc_query_impl[bdc2370c3287c759]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
30: 0x7f5f2600135e - rustc_interface[5a45d25d69207022]::passes::create_and_enter_global_ctxt::<core[2b031b7237be44de]::option::Option<rustc_interface[5a45d25d69207022]::queries::Linker>, rustc_driver_impl[a708e1f659847ef0]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
31: 0x7f5f25fdb916 - rustc_interface[5a45d25d69207022]::interface::run_compiler::<(), rustc_driver_impl[a708e1f659847ef0]::run_compiler::{closure#0}>::{closure#1}
32: 0x7f5f25e71911 - std[cb5a7f0ea0430aa5]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[5a45d25d69207022]::util::run_in_thread_with_globals<rustc_interface[5a45d25d69207022]::util::run_in_thread_pool_with_globals<rustc_interface[5a45d25d69207022]::interface::run_compiler<(), rustc_driver_impl[a708e1f659847ef0]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
33: 0x7f5f25e71dc8 - <<std[cb5a7f0ea0430aa5]::thread::Builder>::spawn_unchecked_<rustc_interface[5a45d25d69207022]::util::run_in_thread_with_globals<rustc_interface[5a45d25d69207022]::util::run_in_thread_pool_with_globals<rustc_interface[5a45d25d69207022]::interface::run_compiler<(), rustc_driver_impl[a708e1f659847ef0]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[2b031b7237be44de]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
34: 0x7f5f25e73381 - std::sys::pal::unix::thread::Thread::new::thread_start::h0f9dd4118f064405
35: 0x7f5f203d8609 - start_thread
at /build/glibc-LcI20x/glibc-2.31/nptl/pthread_create.c:477:8
36: 0x7f5f202fd353 - clone
at /build/glibc-LcI20x/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95
37: 0x0 - <unknown>
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: please attach the file at `/home/nightwish/workspace/compiler/rust_test/rustc-ice-2024-12-31T10_40_48-4321.txt` to your bug report
query stack during panic:
#0 [mir_drops_elaborated_and_const_checked] elaborating drops for `main`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0133, E0277.
For more information about an error, try `rustc --explain E0133`.
Anything else?
No response