Description
Code
#![feature(extern_types)]
#![feature(unsized_locals)]
extern {
type Device;
}
unsafe fn make_device() -> Box<Device> {
Box::from_raw(0 as *mut _)
}
fn main() {
let d: Device = unsafe { *make_device() };
}
Meta
rustc --version --verbose
:
rustc 1.50.0-nightly (1c389ffef 2020-11-24)
Error output
thread 'rustc' panicked at 'assertion failed: `(left == right)`
left: `false`,
right: `true`', compiler/rustc_codegen_llvm/src/builder.rs:445:9
Backtrace
stack backtrace:
0: rust_begin_unwind
at /rustc/1c389ffeff814726dec325f0f2b0c99107df2673/library/std/src/panicking.rs:493:5
1: core::panicking::panic_fmt
at /rustc/1c389ffeff814726dec325f0f2b0c99107df2673/library/core/src/panicking.rs:92:14
2: <rustc_codegen_llvm::builder::Builder as rustc_codegen_ssa::traits::builder::BuilderMethods>::load_operand
3: rustc_codegen_ssa::mir::operand::<impl rustc_codegen_ssa::mir::FunctionCx<Bx>>::codegen_consume
4: rustc_codegen_ssa::mir::operand::<impl rustc_codegen_ssa::mir::FunctionCx<Bx>>::codegen_operand
5: rustc_codegen_ssa::mir::block::<impl rustc_codegen_ssa::mir::FunctionCx<Bx>>::codegen_block
6: rustc_codegen_ssa::mir::codegen_mir
7: rustc_codegen_ssa::base::codegen_instance
8: <rustc_middle::mir::mono::MonoItem as rustc_codegen_ssa::mono_item::MonoItemExt>::define
9: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
10: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
11: rustc_codegen_llvm::base::compile_codegen_unit
12: rustc_codegen_ssa::base::codegen_crate
13: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
14: rustc_interface::queries::Queries::ongoing_codegen
15: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
16: rustc_span::with_source_map
17: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: internal compiler error: unexpected panic
Metadata
Metadata
Assignees
Labels
Category: This is a bug.`#![feature(extern_types)]``#![feature(unsized_locals)]`Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Status: This bug is tracked inside the repo by a `known-bug` test.Relevant to the compiler team, which will review and decide on the PR/issue.ICE tracked in rust-lang/glacier.This issue requires a nightly compiler in some way.
Activity
SNCPlay42 commentedon Nov 25, 2020
It seems clear to me that this shouldn't compile: there's no way to determine, even at run time, how many bytes of storage
d
needs (short of looking at the external code to see the size ofDevice
, or calling some function in the compiled extern code to ask what the size ofDevice
is, neither of which can be done in general). So we just can't support an unsized local of an extern type.But this presents a pretty big problem: unsized locals of
?Sized
generic parameter types. This program can't be correct (and indeed it ICEs the same way as the original code), but which part of it is in error?It seems to me that these features can't coexist as they are currently -
extern_types
breaksunsized_locals
's fundamental assumption that at runtime we can determine the size of any type, even?Sized
ones.I think this needs discussion from the lang team.
Enselic commentedon Aug 29, 2023
Triage: Still reproduces in Playground on current nightly, now at
compiler/rustc_codegen_llvm/src/builder.rs:491:9
.extern
types) #115709matthiaskrgr commentedon Jan 9, 2024
Auto merge of rust-lang#137944 - davidtwco:sized-hierarchy, r=<try>
31 remaining items