{"record":{"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/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/compiler/rustc_codegen_gcc/src/builder.rs#L1321-L1357","documentation":"Builder::pointercast (builder.rs:1339) only implements three of the four (src_is_pointer, dst_is_pointer) combinations. The (true, false) arm — casting a pointer-typed value to a non-pointer destination type via pointercast — is unimplemented!(). GCC's gccjit API does not expose a direct pointer-to-integer reinterpret through this path, so the backend panics instead of emitting wrong code.","triggerScenarios":"Any Rust IR operation that lowers to BuilderMethods::pointercast where the source is a pointer and the destination is an integer/raw type — e.g. transmute/cast of a reference into a usize, ptr.addr_of()-style pointer-to-int reinterpretation generated during codegen.","commonSituations":"Compiling code that reinterprets pointers as integers (common in serialization, hashing of pointers, FFI marshalling, custom allocators) with the GCC backend; situations where MIR lowering calls pointercast for a ptr->int shape.","solutions":["Fall back to the LLVM backend for the crate that triggers it.","Rewrite the reinterpretation to use an explicit ptr-to-int cast that lowers through a different builder method (e.g. inttoptr/ptrtoint intrinsics rather than pointercast).","Avoid transmute between pointer and integer types; use the standard addr_of/ from/into patterns that lower to supported ops.","Patch pointercast to lower (true, false) via context.new_cast through an integral type of the pointer's size."],"exampleFix":"// before: transmute that lowers to a pointer->non-pointer pointercast\nlet raw: usize = std::mem::transmute(&value);\n\n// after: use the supported cast path\nlet raw: usize = (&value) as *const _ as usize;","handlingStrategy":"validation","validationCode":"# Before enabling the gcc backend, search for pointer->int reinterpretations.\ngrep -rn 'transmute.*&\\|as \\*const .* as usize\\|as \\*mut .* as usize' src/ || true\n# Rewrite any matches to use supported cast paths before building with gcc.","typeGuard":"// Prefer explicit ptr-to-int casts that do not lower to pointercast's (true,false) arm.\nfn ptr_to_int<T>(p: *const T) -> usize { p as usize }  // use `as`, not transmute","tryCatchPattern":"if ! RUSTFLAGS=\"-Zcodegen-backend=gcc\" cargo build 2>err.log; then\n  grep -q 'not implemented' err.log && { echo 'pointercast gap; using LLVM'; cargo build; }\nfi","preventionTips":["Avoid transmute between pointers and integers; use `as` casts.","Build a CI lane with the LLVM backend to keep the crate valid while the gcc backend catches up.","Audit serialization/hashing/allocator code for pointer-to-int reinterprets."],"tags":["rust","rustc-codegen-gcc","pointercast","codegen","casts"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}