{"id":"9e92111d5dae63a1","repo":"rust-lang/rust","slug":"unsupported-float-self","errorCode":null,"errorMessage":"unsupported float: {self:?}","messagePattern":"unsupported float: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"compiler/rustc_abi/src/callconv/reg.rs","lineNumber":70,"sourceCode":"impl Reg {\n    pub fn align<C: HasDataLayout>(&self, cx: &C) -> Align {\n        let dl = cx.data_layout();\n        match self.kind {\n            RegKind::Integer => match self.size.bits() {\n                1 => dl.i1_align,\n                2..=8 => dl.i8_align,\n                9..=16 => dl.i16_align,\n                17..=32 => dl.i32_align,\n                33..=64 => dl.i64_align,\n                65..=128 => dl.i128_align,\n                _ => panic!(\"unsupported integer: {self:?}\"),\n            },\n            RegKind::Float => match self.size.bits() {\n                16 => dl.f16_align,\n                32 => dl.f32_align,\n                64 => dl.f64_align,\n                128 => dl.f128_align,\n                _ => panic!(\"unsupported float: {self:?}\"),\n            },\n            RegKind::Vector { .. } => dl.rust_vector_align(self.size),\n        }\n    }\n}\n","sourceCodeStart":52,"sourceCodeEnd":76,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_abi/src/callconv/reg.rs#L52-L76","documentation":"This panic fires in `Reg::align` for a `RegKind::Float` whose bit width is not 16/32/64/128 — the only float sizes the data layout has alignment entries for (`f16_align`, `f32_align`, `f64_align`, `f128_align`). It is an internal invariant: the float register constructors (`Reg::f32`, `f64`, `f128`) always produce supported widths, so an unsupported size means a codegen or target-spec bug rather than user-level input.","triggerScenarios":"Constructing `Reg { kind: RegKind::Float, size }` with a size whose `.bits()` is not in {16,32,64,128} and then calling `.align(cx)` against any `HasDataLayout` (e.g. while computing a calling-convention slot for a float argument).","commonSituations":"A target data layout missing or misordering float alignment fields, a custom backend introducing a non-standard float width (e.g. 80-bit x87 extended, 64-byte vectors reported as floats), or an internal refactor that changed how float primitives map to `Reg` sizes.","solutions":["Confirm the target's `data_layout` declares float alignments for 16/32/64/128 bits and that the target actually supports the float width you intend to pass.","Trace the caller building the float `Reg` (search for `RegKind::Float` and `Reg::f*`) and ensure it uses the canonical constructors rather than a hand-built size.","If a genuinely new float width is required, first add the matching `fN_align` field to `TargetDataLayout` and a match arm here.","Report an ICE with the backtrace if it reproduces on stock `rustc` with a built-in target."],"exampleFix":"// before\nlet f = Reg { kind: RegKind::Float, size: Size::from_bits(80) };\nlet a = f.align(&dl); // panic: unsupported float\n\n// after — use a supported width, or model 80-bit as a memory/Primitive::Float(F64) slot\nlet f = Reg::f64();\nlet a = f.align(&dl);","handlingStrategy":"validation","validationCode":"// Reg::align panics on float sizes outside {16, 32, 64, 128} bits.\nuse rustc_abi::{Reg, RegKind};\nfn supported_float_align(reg: &Reg) -> bool {\n    if !matches!(reg.kind, RegKind::Float) { return true; }\n    matches!(reg.size.bits(), 16 | 32 | 64 | 128)\n}\n// caller: if supported_float_align(&reg) { reg.align(cx) } else { /* skip / report */ }","typeGuard":"fn is_supported_float_reg(reg: &Reg) -> bool {\n    matches!(reg.kind, RegKind::Float) && supported_float_align(reg)\n}","tryCatchPattern":"let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| reg.align(cx)));\nmatch result {\n    Ok(align) => { /* use align */ }\n    Err(_) => { eprintln!(\"unsupported float reg: {:?}\", &reg); /* recover */ }\n}","preventionTips":["Build float Regs only via Reg::f32 / Reg::f64 / Reg::f128; never hand-construct a Float Reg with an off-size.","Whitelist float element sizes at the data-layout trust boundary; the only legal float widths are 16/32/64/128 bits.","When lowering an external type description (C ABI, DWARF, IR) into Primitive::Float, reject anything not in the supported set before it reaches Reg::align."],"tags":["rustc","abi","codegen","float","ice"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}