rust-lang / rust-lang/rust

[ICE]: OperandValue cannot be a pointer

Open
#162,861 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-coerce_unsized I-ICE needs-triage T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

snippet:

#![feature(coerce_unsized)]
#![feature(unsize)]

use std::{marker::Unsize, ops::CoerceUnsized};

#[repr(C)]
struct Ptr<T: ?Sized>(Box<T>);
impl<T, U: ?Sized> CoerceUnsized<Ptr<U>> for Ptr<T> where T: Unsize<U> {}

fn main() {
    Ptr(Box::new(5)) as Ptr<dyn std::any::Any>;
}

Version information

rustc 1.100.0-nightly (92801ede8 2026-09-16)
binary: rustc
commit-hash: 92801ede88f6c10e34df6976a4cfde40142585f2
commit-date: 2026-09-16
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.1

Possibly related line of code:
https://github.com/rust-lang/rust/blob/92801ede88f6c10e34df6976a4cfde40142585f2/compiler/rustc_codegen_ssa/src/mir/operand.rs#L102-L114

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

Program output

error: internal compiler error: /rustc-dev/92801ede88f6c10e34df6976a4cfde40142585f2/compiler/rustc_codegen_ssa/src/mir/operand.rs:108:32: OperandValue cannot be a pointer: Ref(PlaceValue { llval: (ptr:  %1 = alloca [8 x i8], align 8), llextra: None, align: Align(8 bytes) })


thread 'rustc' (1734874) panicked at /rustc-dev/92801ede88f6c10e34df6976a4cfde40142585f2/compiler/rustc_codegen_ssa/src/mir/operand.rs:108:32:
OperandValue cannot be a pointer: Ref(PlaceValue { llval: (ptr:  %1 = alloca [8 x i8], align 8), llextra: None, align: Align(8 bytes) })
stack backtrace:
   0:     0x7f0f59481956 - <<std[720dee8f8bfdc813]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[bf8227dabe305445]::fmt::Display>::fmt
   1:     0x7f0f59c09cd1 - core[bf8227dabe305445]::fmt::write
   2:     0x7f0f5949691c - <std[720dee8f8bfdc813]::sys::stdio::unix::Stderr as core[bf8227dabe305445]::io::write::Write>::write_fmt
   3:     0x7f0f5945445a - std[720dee8f8bfdc813]::panicking::default_hook::{closure#0}
   4:     0x7f0f59475f03 - std[720dee8f8bfdc813]::panicking::default_hook
   5:     0x7f0f5818509f - std[720dee8f8bfdc813]::panicking::update_hook::<alloc[fc315bf851adfeb5]::boxed::Box<rustc_driver_impl[249e893f59edbaf7]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f0f594763a2 - std[720dee8f8bfdc813]::panicking::panic_with_hook
   7:     0x7f0f59454512 - std[720dee8f8bfdc813]::panicking::panic_handler::{closure#0}
   8:     0x7f0f5944b339 - std[720dee8f8bfdc813]::sys::backtrace::__rust_end_short_backtrace::<std[720dee8f8bfdc813]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f0f594560ed - __rustc[ea5107eac9713e7a]::rust_begin_unwind
  10:     0x7f0f55f06c3c - core[bf8227dabe305445]::panicking::panic_fmt
  11:     0x7f0f552b84f9 - rustc_span[28e02c8c6c40f43e]::macros::bug_impl
  12:     0x7f0f55ed374e - <rustc_codegen_ssa[5b6ad83e4b223464]::mir::FunctionCx<rustc_codegen_llvm[fda964c0a81613cf]::builder::GenericBuilder<rustc_codegen_llvm[fda964c0a81613cf]::context::FullCx>>>::codegen_rvalue_operand
  13:     0x7f0f5b2355ea - rustc_codegen_ssa[5b6ad83e4b223464]::mir::codegen_mir::<rustc_codegen_llvm[fda964c0a81613cf]::builder::GenericBuilder<rustc_codegen_llvm[fda964c0a81613cf]::context::FullCx>>
  14:     0x7f0f59ceda00 - rustc_codegen_llvm[fda964c0a81613cf]::base::compile_codegen_unit::module_codegen
  15:     0x7f0f5b021dc6 - <rustc_codegen_llvm[fda964c0a81613cf]::LlvmCodegenBackend as rustc_codegen_ssa[5b6ad83e4b223464]::traits::backend::ExtraBackendMethods>::compile_codegen_unit
  16:     0x7f0f5b01e11c - rustc_codegen_ssa[5b6ad83e4b223464]::base::codegen_crate::<rustc_codegen_llvm[fda964c0a81613cf]::LlvmCodegenBackend, rustc_codegen_llvm[fda964c0a81613cf]::ModuleLlvm>
  17:     0x7f0f5b01c36e - <rustc_codegen_llvm[fda964c0a81613cf]::LlvmCodegenBackend as rustc_codegen_ssa[5b6ad83e4b223464]::traits::backend::CodegenBackend>::codegen_crate
  18:     0x7f0f5b01baf3 - <rustc_interface[758637dfb6969226]::queries::Linker>::codegen_and_build_linker
  19:     0x7f0f5aef944c - rustc_interface[758637dfb6969226]::interface::run_compiler::<(), rustc_driver_impl[249e893f59edbaf7]::run_compiler::{closure#0}>::{closure#2}
  20:     0x7f0f5af71402 - std[720dee8f8bfdc813]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[758637dfb6969226]::util::run_in_thread_with_globals<rustc_interface[758637dfb6969226]::util::run_in_thread_pool_with_globals<rustc_interface[758637dfb6969226]::interface::run_compiler<(), rustc_driver_impl[249e893f59edbaf7]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  21:     0x7f0f5af711ad - <std[720dee8f8bfdc813]::thread::lifecycle::spawn_unchecked<rustc_interface[758637dfb6969226]::util::run_in_thread_with_globals<rustc_interface[758637dfb6969226]::util::run_in_thread_pool_with_globals<rustc_interface[758637dfb6969226]::interface::run_compiler<(), rustc_driver_impl[249e893f59edbaf7]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[bf8227dabe305445]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  22:     0x7f0f5af7bee1 - <std[720dee8f8bfdc813]::sys::thread::unix::Thread>::new::thread_start
  23:     0x7f0f53c980a2 - <unknown>
  24:     0x7f0f53d2080c - <unknown>
  25:                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.100.0-nightly (92801ede8 2026-09-16) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
error: aborting due to 1 previous error


@rustbot label +F-coerce_unsized +F-unsize

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by compiling the provided a.rs reproducer with the reported nightly toolchain and inspect compiler/rustc_codegen_ssa/src/mir/operand.rs:102-114, especially the codegen path named in the backtrace. Trace how the CoerceUnsized conversion reaches OperandValue and confirm the issue no longer produces the internal compiler error. Add a regression test if the relevant compiler test location is identified during investigation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.