Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

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

Closed
est31 opened this issue Jan 1, 2017 · 2 comments
Closed

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

est31 opened this issue Jan 1, 2017 · 2 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@est31
Copy link
Member

est31 commented Jan 1, 2017

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

@kennytm
Copy link
Member

kennytm commented May 4, 2017

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))

@frewsxcv frewsxcv added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jun 4, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 22, 2017
@eddyb
Copy link
Member

eddyb commented Jan 12, 2018

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,

topecongiro added a commit to topecongiro/rust that referenced this issue Jan 14, 2018
Add a test for rust-lang#38763.
Update a test for rust-lang#45662.
topecongiro added a commit to topecongiro/rust that referenced this issue Jan 14, 2018
@bors bors closed this as completed in fe2fb24 Jan 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in 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

Successfully merging a pull request may close this issue.

5 participants