Skip to content

[i128] ICE when calling function with #[repr(C)]'d tuple struct #38763

Closed
@est31

Description

@est31
Member

The following code causes an ICE on current master (ac5cd3b):

#![feature(i128_type)]

#[repr(C)]
struct Foo(i128);

#[link(name = "test", kind = "static")]
extern "C" {
    fn foo(f: Foo) -> Foo;
}

fn main() {
    unsafe {
        foo(Foo(1));
    }
}

ICE message:

error: internal compiler error: src/librustc_trans/cabi_x86_64.rs:321: llregtype: unhandled class

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

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:423
note: Run with `RUST_BACKTRACE=1` for a backtrace.

cc #35118 (tracking issue)
cc @nagisa , me

Activity

kennytm

kennytm commented on May 4, 2017

@kennytm
Member

Still ICE-ing but with a different stack trace.

rustc 1.19.0-nightly (6a5fc9eec 2017-05-02)
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 'called `Option::unwrap()` on a `None` value', /checkout/src/libcore/option.rs:329
stack backtrace:
<snip>
   9: core::panicking::panic
             at /checkout/src/libcore/panicking.rs:49
  10: rustc_trans::cabi_x86_64::compute_abi_info::{{closure}}
  11: rustc_trans::abi::FnType::adjust_for_abi
  12: rustc_trans::mir::block::<impl rustc_trans::mir::MirContext<'a, 'tcx>>::trans_block
  13: rustc_trans::mir::trans_mir
  14: rustc_trans::trans_item::TransItem::define
  15: rustc_trans::base::trans_crate
  16: rustc_driver::driver::phase_4_translate_to_llvm
<snip>

Relevant line I guess (there is only one unwrap right?):

arg.cast_to(ccx, cast_target(cls.as_ref().unwrap(), size))

added
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
on Jun 4, 2017
eddyb

eddyb commented on Jan 12, 2018

@eddyb
Member

This is very suspicious - that unwrap can't possibly fail - because it only runs when in_mem is false but when cls is Err, in_mem is true:

let in_mem = match cls {
Err(Memory) => true,

added a commit that references this issue on Jan 25, 2018

Rollup merge of rust-lang#47437 - eddyb:issue-38763, r=nagisa

fe2fb24
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.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @eddyb@kennytm@frewsxcv@Mark-Simulacrum@est31

      Issue actions

        [i128] ICE when calling function with #[repr(C)]'d tuple struct · Issue #38763 · rust-lang/rust