Skip to content

ICE getting discriminant of #[repr(i128)] enum #43398

Closed

Description

@durka

ICE occurs whether we use intrinsics::discriminant_value or mem::discriminant. cc #35118 #24263

STR

#![feature(core_intrinsics)]
#![feature(i128_type)]

#[repr(i128)]
enum Big { A, B }

fn main() {
    unsafe {
        println!("{} {:?}",
            std::intrinsics::discriminant_value(&Big::A),
            std::mem::discriminant(&Big::B));
    }
}

ICE

thread 'rustc' panicked at 'assertion failed: bits <= 64', src/librustc_trans/adt.rs:368:4
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
   1: std::panicking::default_hook::{{closure}}
   2: std::panicking::default_hook
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::begin_panic_new
   5: rustc_trans::adt::load_discr
   6: rustc_trans::adt::trans_get_discr
   7: rustc_trans::intrinsic::trans_intrinsic_call
   8: rustc_trans::mir::block::<impl rustc_trans::mir::MirContext<'a, 'tcx>>::trans_terminator
   9: rustc_trans::mir::trans_mir
  10: rustc_trans::trans_item::TransItem::define
  11: rustc_trans::base::trans_crate::module_translation
  12: rustc_trans::base::trans_crate
  13: rustc_driver::driver::phase_4_translate_to_llvm
  14: rustc_driver::driver::compile_input::{{closure}}
  15: rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}
  16: rustc_driver::driver::phase_3_run_analysis_passes
  17: rustc_driver::driver::compile_input
  18: rustc_driver::run_compiler

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    C-bugCategory: This is a bug.
    on Jul 26, 2017
  2. varkor commented on May 3, 2018

    @varkor
    Contributor

    The updated example no longer ICEs.

  3. jakubadamw commented on Jul 14, 2019

    @jakubadamw
    Contributor

    @Mark-Simulacrum, this can be closed as it no longer ICEs.

  4. Mark-Simulacrum commented on Jul 14, 2019

    @Mark-Simulacrum
    Member

    Actually, presumably, E-needstest.

  5. added
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    on Jul 14, 2019
  6. added
    E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
    on Jul 15, 2019
  7. added a commit that references this issue on Aug 5, 2019
  8. added a commit that references this issue on Aug 7, 2019
  9. added 2 commits that reference this issue on Aug 8, 2019
  10. added a commit that references this issue on Aug 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.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