{"id":"4979e799c746a6fd","repo":"rust-lang/rust","slug":"non-array-a-value","errorCode":null,"errorMessage":"non-array a value","messagePattern":"non-array a value","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/rustc_codegen_gcc/src/int.rs","lineNumber":357,"sourceCode":"    ) -> (RValue<'gcc>, RValue<'gcc>) {\n        let a_type = lhs.get_type();\n        let b_type = rhs.get_type();\n        debug_assert!(a_type.dyncast_array().is_some());\n        debug_assert!(b_type.dyncast_array().is_some());\n        let overflow_type = self.i32_type;\n        let overflow_param_type = overflow_type.make_pointer();\n        let res_type = a_type;\n\n        let overflow_value =\n            self.current_func().new_local(self.location, overflow_type, \"overflow\");\n        let overflow_addr = overflow_value.get_address(self.location);\n\n        let param_a = self.context.new_parameter(self.location, a_type, \"a\");\n        let param_b = self.context.new_parameter(self.location, b_type, \"b\");\n        let param_overflow =\n            self.context.new_parameter(self.location, overflow_param_type, \"overflow\");\n\n        let a_elem_type = a_type.dyncast_array().expect(\"non-array a value\");\n        debug_assert!(a_elem_type.is_integral());\n        let res_ty = match width {\n            32 => self.tcx.types.i32,\n            64 => self.tcx.types.i64,\n            128 => self.tcx.types.i128,\n            _ => unreachable!(\"unexpected integer size\"),\n        };\n        let layout = self\n            .tcx\n            .layout_of(ty::TypingEnv::fully_monomorphized().as_query_input(res_ty))\n            .unwrap();\n\n        let arg_abi = ArgAbi { layout, mode: PassMode::Direct(ArgAttributes::new()) };\n        let mut fn_abi = FnAbi {\n            args: vec![arg_abi.clone(), arg_abi.clone(), arg_abi.clone()].into_boxed_slice(),\n            ret: arg_abi,\n            c_variadic: false,\n            fixed_count: 3,","sourceCodeStart":339,"sourceCodeEnd":375,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_codegen_gcc/src/int.rs#L339-L375","documentation":"In `CodegenCx::operation_with_overflow` (the helper invoked for non-`__builtin_*` overflow ops), the code asserts that `lhs`'s type is an array (the i128/u128-as-two-i64 representation) and recovers its element type via `dyncast_array().expect(\"non-array a value\")`. If `lhs.get_type()` is not an array — e.g. a native int slipped through, or a pointer/aggregate — the expect fails.","triggerScenarios":"`operation_with_overflow` is called with an `lhs` whose GCC type is not the 2-element array used for non-native 128-bit ints. Reached from `gcc_checked_binop` after it has already chosen the non-`__builtin_*` path, so the type classification upstream (`is_native_int_type`) and the assertion here disagree.","commonSituations":"Same root family as 134–136: type-classification mismatch, custom ABI/target, or a refactor that changed the array representation of i128/u128. Often co-occurs with one of those.","solutions":["Confirm `is_native_int_type(lhs.get_type())` returned false (otherwise `__builtin_*_overflow` should have been used instead).","Dump `lhs.get_type()` to confirm whether it is really an array; if not, the classification helpers are wrong.","Verify the i128/u128 array layout on this libgccjit version — `concat_low_high` and `dyncast_array` must agree.","If a new non-array non-native type is legitimate, redesign `operation_with_overflow` rather than weakening the expect."],"exampleFix":"// before\nlet a_elem_type = a_type.dyncast_array().expect(\"non-array a value\");\n\n// after\nlet a_elem_type = a_type.dyncast_array().unwrap_or_else(|| {\n    panic!(\"operation_with_overflow: lhs is not an i128/u128 array: {:?}\", a_type);\n});","handlingStrategy":"type-guard","validationCode":"// operation_with_overflow requires lhs.get_type().dyncast_array().is_some().\nlet a_type = lhs.get_type();\nif a_type.dyncast_array().is_none() {\n    return Err(\"operation_with_overflow: lhs type is not a gccjit array (expected i128/u128 emulation)\");\n}\nbuilder.operation_with_overflow(func_name, lhs, rhs, width)","typeGuard":"/// True when the value's gccjit type is the 2-element array used to\n/// emulate a non-native integer (i128/u128 on 32-bit targets).\nfn is_emulated_int_array<'gcc>(value: gccjit::RValue<'gcc>) -> bool {\n    value.get_type().dyncast_array().is_some()\n}\n\nif is_emulated_int_array(lhs) {\n    builder.operation_with_overflow(func_name, lhs, rhs, width)\n}","tryCatchPattern":null,"preventionTips":["operation_with_overflow is the non-native overflow helper; only call it for i128/u128 values, which are represented as gccjit arrays on 32-bit targets.","Build 128-bit constants through gcc_int/gcc_uint_big/concat_low_high so they carry the array type, not a raw scalar.","Add a debug_assert!(a_type.dyncast_array().is_some()) at the entry of any helper that funnels into operation_with_overflow."],"tags":["rustc-codegen-gcc","ice","overflow","i128","libgccjit"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}