{"id":"f0a595a1e0a0ce7c","repo":"rust-lang/rust","slug":"not-implemented-f0a595","errorCode":null,"errorMessage":"not implemented","messagePattern":"not implemented","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/rustc_codegen_gcc/src/builder.rs","lineNumber":1339,"sourceCode":"\n    fn pointercast(&mut self, value: RValue<'gcc>, dest_ty: Type<'gcc>) -> RValue<'gcc> {\n        let val_type = value.get_type();\n        match (type_is_pointer(val_type), type_is_pointer(dest_ty)) {\n            (false, true) => {\n                // NOTE: Projecting a field of a pointer type will attempt a cast from a signed char to\n                // a pointer, which is not supported by gccjit.\n                self.cx.context.new_cast(\n                    self.location,\n                    self.inttoptr(value, val_type.make_pointer()),\n                    dest_ty,\n                )\n            }\n            (false, false) => {\n                // When they are not pointers, we want a transmute (or reinterpret_cast).\n                self.bitcast(value, dest_ty)\n            }\n            (true, true) => self.cx.context.new_cast(self.location, value, dest_ty),\n            (true, false) => unimplemented!(),\n        }\n    }\n\n    /* Comparisons */\n    fn icmp(&mut self, op: IntPredicate, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {\n        self.gcc_icmp(op, lhs, rhs)\n    }\n\n    fn fcmp(&mut self, op: RealPredicate, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {\n        // LLVM has a concept of \"unordered compares\", where eg ULT returns true if either the two\n        // arguments are unordered (i.e. either is NaN), or the lhs is less than the rhs. GCC does\n        // not natively have this concept, so in some cases we must manually handle NaNs\n        let must_handle_nan = match op {\n            RealPredicate::RealPredicateFalse => unreachable!(),\n            RealPredicate::RealOEQ => false,\n            RealPredicate::RealOGT => false,\n            RealPredicate::RealOGE => false,\n            RealPredicate::RealOLT => false,","sourceCodeStart":1321,"sourceCodeEnd":1357,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_codegen_gcc/src/builder.rs#L1321-L1357","documentation":"Thrown by `pointercast` in the `(true, false)` arm of its match on `(type_is_pointer(val_type), type_is_pointer(dest_ty))` — i.e. casting a pointer-typed value to a non-pointer destination type via `unimplemented!()`. The backend handles ptr→ptr, non-ptr→ptr (via `inttoptr`), and non-ptr→non-ptr (transmute via `bitcast`), but a direct pointer-to-integer reinterpretation routed through `pointercast` is not implemented and panics.","triggerScenarios":"rustc emits a `pointercast` whose source is a pointer and whose destination type is an integer or aggregate (not itself a pointer), instead of routing it through `ptrtoint`. This arm fires for pointer-to-aggregate transmutes, union field projections of pointer type, or FFI casts that lower to a pointer→non-pointer `pointercast`.","commonSituations":"Nightly rustc changes to how `mem::transmute` of pointer-sized data, `#[repr(C)]` unions, or FFI structs holding pointers are lowered. Hits crates doing raw pointer reinterpretation or transmute between pointer and integer-sized types under `-Zcodegen-backend=gcc`.","solutions":["Update rustc_codegen_gcc to the commit matching your rustc toolchain","If you control the codegen call site, route pointer→integer casts through `ptrtoint` + `intcast` instead of `pointercast`","Implement the missing arm using the existing `inttoptr`/`ptrtoint` helpers","Report with a minimal reproducer (transmute/union access) to rustc_codegen_gcc"],"exampleFix":"// before\n(true, false) => unimplemented!(),\n\n// after\n(true, false) => {\n    // pointer -> non-pointer: reinterpret the address bits\n    let usize_value = self.cx.context.new_cast(None, value, self.cx.type_isize());\n    self.intcast(usize_value, dest_ty, false)\n}","handlingStrategy":"fallback","validationCode":"// pointercast hits unimplemented!() in the (pointer, non-pointer) arm.\n// Detect that case and route to ptrtoint instead of pointercast.\nlet from_ptr = type_is_pointer(value.get_type());\nlet to_ptr = type_is_pointer(dest_ty);\nif from_ptr && !to_ptr {\n    return builder.ptrtoint(value, dest_ty);\n}\n// otherwise pointercast is safe (both ptr or both non-ptr)","typeGuard":null,"tryCatchPattern":"// These panics abort the compiler process; if you drive cg_gcc as a library,\n// isolate the call and fall back to an explicit ptrtoint on panic.\nmatch std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {\n    builder.pointercast(value, dest_ty)\n})) {\n    Ok(v) => v,\n    Err(_) => builder.ptrtoint(value, dest_ty),\n}","preventionTips":["Never rely on pointercast for pointer-to-non-pointer conversions; call ptrtoint explicitly.","When porting reinterpret_cast/transmute-style code, confirm both the operand and target are pointers, or both are non-pointers, before calling pointercast.","Centralize cast dispatch in one helper so the (ptr, non-ptr) case always redirects to ptrtoint."],"tags":["rust","codegen","gcc","gccjit","pointer","cast","unimplemented"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}