Skip to content

ICE in FieldPlacement::count atop 32-bit host with 64-bit target  #57038

Closed
@pnkfelix

Description

@pnkfelix

While exploring building a cross-compiler and running the test suite on it, I found the following issue:

Using a config.toml with:

host = ["x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu"]
target = ["x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu"]

and then doing x.py test eventually hits this problem:

./build/i686-unknown-linux-gnu/stage1/bin/rustc --target=x86_64-unknown-linux-gnu -O /tmp/huge-enum.rs
warning: unused variable: `big`
  --> /tmp/huge-enum.rs:23:9
   |
23 |     let big: Option<[u32; (1<<45)-1]> = None;
   |         ^^^ help: consider using `_big` instead
   |
   = note: #[warn(unused_variables)] on by default

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `4294967295`,
 right: `35184372088831`', src/librustc_target/abi/mod.rs:716:17
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

error: internal compiler error: unexpected panic

The reason for this ICE is due to a mistake in rustc's internal API here:

impl FieldPlacement {
pub fn count(&self) -> usize {
match *self {
FieldPlacement::Union(count) => count,
FieldPlacement::Array { count, .. } => {
let usize_count = count as usize;
assert_eq!(usize_count as u64, count);
usize_count
}
FieldPlacement::Arbitrary { ref offsets, .. } => offsets.len()
}
}

As @nagisa points out on Zulip, the compiler should not be using usize except for its own indices "and other memory-ey things"

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions