Description
auto-reduced (treereduce-rust):
#[repr(align(536870912))]
enum Aligned {
Zero = 0,
One = 1,
}
fn main() {
let aligned = Aligned::Zero;
assert_eq!(tou8(Aligned::Zero), 0);
}
fn tou8(al: Aligned) -> u8 {
al as u8
}
original:
// run-pass
// allows aligned custom discriminant enums to cast into other types
// See the issue #92464 for more info
#[repr(align(536870912))]
#[repr(align(8))]
enum Aligned {
Zero = 0,
One = 1,
}
fn main() {
let aligned = Aligned::Zero;
let fo = aligned as u8;
println!("foo {}", fo);
assert_eq!(fo, 0);
println!("{}", tou8(Aligned::Zero));
assert_eq!(tou8(Aligned::Zero), 0);
}
#[inline(never)]
fn tou8(al: Aligned) -> u8 {
// Cast behind a function call so ConstProp does not see it
// (so that we can test codegen).
al as u8
}
Version information
rustc 1.76.0-nightly (d5fab3376 2023-12-02)
binary: rustc
commit-hash: d5fab33766917085588d9bb4fb9477776695d98b
commit-date: 2023-12-02
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.5
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcodegen-backend=cranelift
Program output
warning: unused variable: `aligned`
--> /tmp/icemaker_global_tempdir.IhQoDdu5PZ0P/rustc_testrunner_tmpdir_reporting.orosvbyC2kie/mvce.rs:9:9
|
9 | let aligned = Aligned::Zero;
| ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_aligned`
|
= note: `#[warn(unused_variables)]` on by default
warning: variant `One` is never constructed
--> /tmp/icemaker_global_tempdir.IhQoDdu5PZ0P/rustc_testrunner_tmpdir_reporting.orosvbyC2kie/mvce.rs:5:5
|
3 | enum Aligned {
| ------- variant in this enum
4 | Zero = 0,
5 | One = 1,
| ^^^
|
= note: `#[warn(dead_code)]` on by default
thread '<unnamed>' panicked at /rust/deps/cranelift-codegen-0.102.0/src/isa/x64/abi.rs:957:46:
Offset in NominalSPOffset is greater than 2GB; should hit impl limit first: TryFromIntError(())
stack backtrace:
0: 0x7f5f0f76150c - std::backtrace_rs::backtrace::libunwind::trace::h479849121ff49a5d
at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
1: 0x7f5f0f76150c - std::backtrace_rs::backtrace::trace_unsynchronized::hc9644f16de94df45
at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7f5f0f76150c - std::sys_common::backtrace::_print_fmt::h10290334532192e1
at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/sys_common/backtrace.rs:68:5
3: 0x7f5f0f76150c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1f3df53d81057b3e
at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/sys_common/backtrace.rs:44:22
4: 0x7f5f0f7b4540 - core::fmt::rt::Argument::fmt::hb8e319fcddae9a31
at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/core/src/fmt/rt.rs:142:9
5: 0x7f5f0f7b4540 - core::fmt::write::h80be9ea7045f640f
at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/core/src/fmt/mod.rs:1120:17
6: 0x7f5f0f75536f - std::io::Write::write_fmt::h0522d22623a1843b
at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/io/mod.rs:1810:15
7: 0x7f5f0f7612f4 - std::sys_common::backtrace::_print::h11954509d6d4a59e
at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/sys_common/backtrace.rs:47:5
8: 0x7f5f0f7612f4 - std::sys_common::backtrace::print::h89028ceab4fa2c56
at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/sys_common/backtrace.rs:34:9
9: 0x7f5f0f763f87 - std::panicking::default_hook::{{closure}}::ha828cf6bd2b63731
10: 0x7f5f0f763cef - std::panicking::default_hook::h85bef85bc0f3798a
at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/panicking.rs:292:9
11: 0x7f5f0c4f9490 - std[be0bda08bb484463]::panicking::update_hook::<alloc[5e2c4fa57d45c172]::boxed::Box<rustc_driver_impl[7a73365881d43582]::install_ice_hook::{closure#0}>>::{closure#0}
12: 0x7f5f0f7646c8 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::he0dee972ea8e9cc9
at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/alloc/src/boxed.rs:2021:9
13: 0x7f5f0f7646c8 - std::panicking::rust_panic_with_hook::he9727088864fdef9
at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/panicking.rs:783:13
14: 0x7f5f0f76441e - std::panicking::begin_panic_handler::{{closure}}::h80b7e677079c8e55
at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/panicking.rs:657:13
15: 0x7f5f0f7619d6 - std::sys_common::backtrace::__rust_end_short_backtrace::hd9049e8056407812
at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/sys_common/backtrace.rs:171:18
16: 0x7f5f0f764182 - rust_begin_unwind
at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/panicking.rs:645:5
17: 0x7f5f0f7b0c15 - core::panicking::panic_fmt::h97f53bcafbf77918
at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/core/src/panicking.rs:72:14
18: 0x7f5f0f7b1313 - core::result::unwrap_failed::hcb975e08d9c63ed9
at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/core/src/result.rs:1649:5
19: 0x7f5f001f559f - <cranelift_codegen[d4c1749a8095538]::isa::x64::abi::X64ABIMachineSpec as cranelift_codegen[d4c1749a8095538]::machinst::abi::ABIMachineSpec>::gen_get_stack_addr
20: 0x7f5f00312548 - cranelift_codegen[d4c1749a8095538]::isa::x64::lower::isle::generated_code::constructor_stack_addr_impl::<cranelift_codegen[d4c1749a8095538]::machinst::isle::IsleContext<cranelift_codegen[d4c1749a8095538]::isa::x64::lower::isle::generated_code::MInst, cranelift_codegen[d4c1749a8095538]::isa::x64::X64Backend>>
21: 0x7f5f003144f9 - cranelift_codegen[d4c1749a8095538]::isa::x64::lower::isle::generated_code::constructor_lower::<cranelift_codegen[d4c1749a8095538]::machinst::isle::IsleContext<cranelift_codegen[d4c1749a8095538]::isa::x64::lower::isle::generated_code::MInst, cranelift_codegen[d4c1749a8095538]::isa::x64::X64Backend>>
22: 0x7f5f0015a807 - <cranelift_codegen[d4c1749a8095538]::machinst::lower::Lower<cranelift_codegen[d4c1749a8095538]::isa::x64::lower::isle::generated_code::MInst>>::lower::<cranelift_codegen[d4c1749a8095538]::isa::x64::X64Backend>
23: 0x7f5f00195cad - cranelift_codegen[d4c1749a8095538]::machinst::compile::compile::<cranelift_codegen[d4c1749a8095538]::isa::x64::X64Backend>
24: 0x7f5f00249a3a - <cranelift_codegen[d4c1749a8095538]::isa::x64::X64Backend as cranelift_codegen[d4c1749a8095538]::isa::TargetIsa>::compile_function
25: 0x7f5f002d68cd - <cranelift_codegen[d4c1749a8095538]::context::Context>::compile_stencil
26: 0x7f5f002d65b7 - <cranelift_codegen[d4c1749a8095538]::context::Context>::compile_and_emit
27: 0x7f5f0006bf00 - <cranelift_object[d66c271104bc3a81]::backend::ObjectModule as cranelift_module[4cf4b873220cd41]::module::Module>::define_function_with_control_plane
28: 0x7f5f00025ef2 - rustc_codegen_cranelift[b6b6b84571df3c3b]::driver::aot::module_codegen::{closure#1}
29: 0x7f5efffc2a16 - std[be0bda08bb484463]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_codegen_cranelift[b6b6b84571df3c3b]::driver::aot::module_codegen::{closure#1}, core[9199d425737c1d72]::result::Result<rustc_codegen_cranelift[b6b6b84571df3c3b]::driver::aot::ModuleCodegenResult, alloc[5e2c4fa57d45c172]::string::String>>
30: 0x7f5efffd1616 - <<std[be0bda08bb484463]::thread::Builder>::spawn_unchecked_<rustc_codegen_cranelift[b6b6b84571df3c3b]::driver::aot::module_codegen::{closure#1}, core[9199d425737c1d72]::result::Result<rustc_codegen_cranelift[b6b6b84571df3c3b]::driver::aot::ModuleCodegenResult, alloc[5e2c4fa57d45c172]::string::String>>::{closure#1} as core[9199d425737c1d72]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
31: 0x7f5f0f76e555 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h97e5c9d6b1622657
at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/alloc/src/boxed.rs:2007:9
32: 0x7f5f0f76e555 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb5f6014336ba501b
at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/alloc/src/boxed.rs:2007:9
33: 0x7f5f0f76e555 - std::sys::unix::thread::Thread::new::thread_start::h758e18463c2780d9
at /rustc/d5fab33766917085588d9bb4fb9477776695d98b/library/std/src/sys/unix/thread.rs:108:17
34: 0x7f5f096a59eb - <unknown>
35: 0x7f5f097297cc - <unknown>
36: 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: rustc 1.76.0-nightly (d5fab3376 2023-12-02) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z codegen-backend=cranelift -Z dump-mir-dir=dir
query stack during panic:
end of query stack
warning: 2 warnings emitted