Skip to content

write_volatile causes ICE with zero-sized types. #39827

Closed
@ghost

Description

I tried this code:

fn main () {
    let mut x = ();
    unsafe {
        std::ptr::write_volatile(&mut x, ());
    }
}

I expected to see this happen:

Nothing

Instead, this happened:

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'index out of bounds: the len is 1 but the index is 1', /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/librustc_trans/intrinsic.rs:326

Meta

rustc --version --verbose:

rustc 1.17.0-nightly (956e2bcba 2017-02-12)
binary: rustc
commit-hash: 956e2bcbaa00c05e051718b1375375915064f1c3
commit-date: 2017-02-12
host: x86_64-unknown-linux-gnu
release: 1.17.0-nightly
LLVM version: 3.9

Backtrace:

   1:     0x7fdf6f9393fa - std::sys::imp::backtrace::tracing::imp::write::h3188f035833a2635
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:42
   2:     0x7fdf6f94775f - std::panicking::default_hook::{{closure}}::h6385b6959a2dd25b
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:349
   3:     0x7fdf6f9472fd - std::panicking::default_hook::he4f3b61755d7fa95
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:359
   4:     0x7fdf6f947c07 - std::panicking::rust_panic_with_hook::hf00b8130f73095ec
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:553
   5:     0x7fdf6f947a44 - std::panicking::begin_panic::h6227f62cb2cdaeb4
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:515
   6:     0x7fdf6f9479b9 - std::panicking::begin_panic_fmt::h173eadd80ae64bec
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:499
   7:     0x7fdf6f947947 - rust_begin_unwind
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:475
   8:     0x7fdf6f98323d - core::panicking::panic_fmt::h3b2d1e30090844ff
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libcore/panicking.rs:69
   9:     0x7fdf6f9831e8 - core::panicking::panic_bounds_check::hecd7d6e6ce8d6275
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libcore/panicking.rs:56
  10:     0x7fdf6eb9d8db - rustc_trans::intrinsic::trans_intrinsic_call::h71c3926493851d2f
  11:     0x7fdf6ebaf26a - rustc_trans::mir::block::<impl rustc_trans::mir::MirContext<'bcx, 'tcx>>::trans_block::h7370a41d2cf00e4c
  12:     0x7fdf6eba9498 - rustc_trans::mir::trans_mir::ha7607c24e74fe3fc
  13:     0x7fdf6ebcacee - rustc_trans::trans_item::TransItem::define::h1e41c90c4e3659f0
  14:     0x7fdf6eb42827 - rustc_trans::base::trans_crate::hd0c42f1c088c6870
  15:     0x7fdf6fcebc10 - rustc_driver::driver::phase_4_translate_to_llvm::haac68055ca0e54a5
  16:     0x7fdf6fcb9819 - rustc_driver::driver::compile_input::{{closure}}::ha32b4e7a1ff999dd
  17:     0x7fdf6fcdf091 - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::h16429aca33e82f30
  18:     0x7fdf6fcc85fe - rustc_driver::driver::phase_3_run_analysis_passes::h1b30709031b4f637
  19:     0x7fdf6fcb7775 - rustc_driver::driver::compile_input::h71ecf4df05846d25
  20:     0x7fdf6fd00b62 - rustc_driver::run_compiler::h180324a0694503f7
  21:     0x7fdf6fc1547b - std::panicking::try::do_call::ha2c776608407d6f3
  22:     0x7fdf6f95042a - __rust_maybe_catch_panic
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libpanic_unwind/lib.rs:98
  23:     0x7fdf6fc37021 - <F as alloc::boxed::FnBox<A>>::call_box::h08c51ed50888bb2f
  24:     0x7fdf6f9465c4 - std::sys::imp::thread::Thread::new::thread_start::he018521f53b24939
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/liballoc/boxed.rs:615
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/sys_common/thread.rs:21
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/sys/unix/thread.rs:84
  25:     0x7fdf68784453 - start_thread
  26:     0x7fdf6f6107de - __GI___clone
  27:                0x0 - <unknown>

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions