Skip to content

ICE: by-ref operand OperandRef in trans_rvalue_operand #46152

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
oli-obk opened this issue Nov 21, 2017 · 1 comment
Closed

ICE: by-ref operand OperandRef in trans_rvalue_operand #46152

oli-obk opened this issue Nov 21, 2017 · 1 comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@oli-obk
Copy link
Contributor

oli-obk commented Nov 21, 2017

#![feature(unsize, coerce_unsized)]

#[repr(packed)]
struct UnalignedPtr<'a, T: ?Sized>
where T: 'a,
{
    data: &'a T,
}

fn main() {

    impl<'a, T, U> std::ops::CoerceUnsized<UnalignedPtr<'a, U>> for UnalignedPtr<'a, T>
    where
        T: std::marker::Unsize<U> + ?Sized,
        U: ?Sized,
    { }

    let arr = [1, 2, 3];
    let arr_unaligned: UnalignedPtr<[i32; 3]> = UnalignedPtr { data: &arr };
    let arr_unaligned: UnalignedPtr<[i32]> = arr_unaligned;
}
error: internal compiler error: /checkout/src/librustc_trans/mir/rvalue.rs:246: by-ref operand OperandRef(Ref((%"UnalignedPtr<[i32; 3]>"*:  %_6 = alloca %"UnalignedPtr<[i32; 3]>", align 1), AbiAligned) @ TyLayout { ty: UnalignedPtr<[i32; 3]>, details: LayoutDetails { variants: Single { index: 0 }, fields: Arbitrary { offsets: [Size { raw: 0 }], memory_index: [0] }, abi: Aggregate { sized: true, packed: true }, align: Align { abi: 0, pref: 0 }, size: Size { raw: 8 } } }) in trans_rvalue_operand
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:68
             at src/libstd/sys_common/backtrace.rs:57
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:381
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:391
   4: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:577
   5: std::panicking::begin_panic
             at ./src/libstd/panicking.rs:538
   6: rustc_errors::Handler::bug
             at src/librustc_errors/lib.rs:471
   7: <std::thread::local::LocalKey<T>>::with
             at src/librustc/session/mod.rs:992
             at src/librustc/ty/context.rs:1689
             at src/librustc/ty/context.rs:1678
             at ./src/libstd/thread/local.rs:377
             at ./src/libstd/thread/local.rs:288
   8: rustc::ty::context::tls::with_opt
             at src/librustc/ty/context.rs:1674
             at src/librustc/ty/context.rs:1689
   9: rustc::session::opt_span_bug_fmt
             at src/librustc/session/mod.rs:988
  10: rustc::session::bug_fmt
             at src/librustc/session/mod.rs:972
  11: rustc_trans::mir::rvalue::<impl rustc_trans::mir::MirContext<'a, 'tcx>>::trans_rvalue_operand
             at src/librustc_trans/mir/rvalue.rs:246
  12: rustc_trans::mir::rvalue::<impl rustc_trans::mir::MirContext<'a, 'tcx>>::trans_rvalue
             at src/librustc_trans/mir/rvalue.rs:62
  13: rustc_trans::mir::trans_mir
             at src/librustc_trans/mir/statement.rs:32
             at src/librustc_trans/mir/block.rs:46
             at src/librustc_trans/mir/mod.rs:321
  14: rustc_trans::base::trans_instance
             at src/librustc_trans/base.rs:505
  15: rustc_trans::base::compile_codegen_unit
             at src/librustc_trans/trans_item.rs:73
             at src/librustc_trans/base.rs:1217
             at src/librustc_trans/base.rs:1171
  16: rustc::ty::maps::<impl rustc::ty::maps::queries::compile_codegen_unit<'tcx>>::compute_result
             at src/librustc/ty/maps/plumbing.rs:382
  17: rustc::dep_graph::graph::DepGraph::with_task_impl
             at src/librustc/dep_graph/graph.rs:273
  18: rustc::dep_graph::graph::DepGraph::with_task
             at src/librustc/dep_graph/graph.rs:189
  19: rustc_errors::Handler::track_diagnostics
             at src/librustc/ty/maps/plumbing.rs:472
             at ./src/librustc_errors/lib.rs:534
  20: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
             at src/librustc/ty/maps/plumbing.rs:465
             at src/librustc/ty/maps/plumbing.rs:120
  21: rustc::ty::maps::<impl rustc::ty::maps::queries::compile_codegen_unit<'tcx>>::force
             at src/librustc/ty/maps/plumbing.rs:464
  22: rustc::ty::maps::<impl rustc::ty::maps::queries::compile_codegen_unit<'tcx>>::try_get
             at src/librustc/ty/maps/plumbing.rs:300
             at src/librustc/ty/maps/plumbing.rs:506
  23: rustc::ty::maps::TyCtxtAt::compile_codegen_unit
             at src/librustc/ty/maps/plumbing.rs:545
  24: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::compile_codegen_unit
             at src/librustc/ty/maps/plumbing.rs:538
  25: rustc_trans::base::trans_crate
             at src/librustc_trans/base.rs:892
  26: <rustc_trans::LlvmTransCrate as rustc_trans_utils::trans_crate::TransCrate>::trans_crate
             at src/librustc_trans/lib.rs:182
  27: rustc::util::common::time
             at src/librustc_driver/driver.rs:1106
             at ./src/librustc/util/common.rs:120
  28: rustc_driver::driver::phase_4_translate_to_llvm
             at src/librustc_driver/driver.rs:1105
  29: rustc_driver::driver::compile_input::{{closure}}
             at src/librustc_driver/driver.rs:247
  30: <std::thread::local::LocalKey<T>>::with
             at src/librustc_driver/driver.rs:1089
             at ./src/librustc/ty/context.rs:1662
             at ./src/libstd/thread/local.rs:377
             at ./src/libstd/thread/local.rs:288
  31: rustc::ty::context::tls::enter
             at ./src/librustc/ty/context.rs:1659
  32: <std::thread::local::LocalKey<T>>::with
             at ./src/librustc/ty/context.rs:1646
             at ./src/libstd/thread/local.rs:377
             at ./src/libstd/thread/local.rs:288
  33: rustc_driver::driver::phase_3_run_analysis_passes
             at ./src/librustc/ty/context.rs:1643
             at ./src/librustc/ty/context.rs:1277
             at src/librustc_driver/driver.rs:1010
  34: rustc_driver::driver::compile_input
             at src/librustc_driver/driver.rs:209
  35: rustc_driver::run_compiler
             at src/librustc_driver/lib.rs:253
@kennytm kennytm added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ C-bug Category: This is a bug. labels Nov 21, 2017
bors added a commit that referenced this issue Dec 27, 2017
Add tests to fixed ICEs

Closes #27078. Closes #27985. Closes #39848. Closes #42164.
Closes #42479. Closes #45662. Closes #45965. Closes #46152.
@mikeyhew
Copy link
Contributor

mikeyhew commented Oct 7, 2018

If you replace #[repr(packed)] with #[repr(C)] this ICEs again

EDIT: opened a new issue #54888

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants