{"id":"ee59de8dfccb0be1","repo":"rust-lang/rust","slug":"internal-error-entered-unreachable-code","errorCode":null,"errorMessage":"internal error: entered unreachable code","messagePattern":"internal error: entered unreachable code","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"compiler/rustc_codegen_gcc/src/builder.rs","lineNumber":1353,"sourceCode":"                // 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,\n            RealPredicate::RealOLE => false,\n            RealPredicate::RealONE => false,\n            RealPredicate::RealORD => unreachable!(),\n            RealPredicate::RealUNO => unreachable!(),\n            RealPredicate::RealUEQ => false,\n            RealPredicate::RealUGT => true,\n            RealPredicate::RealUGE => true,\n            RealPredicate::RealULT => true,\n            RealPredicate::RealULE => true,\n            RealPredicate::RealUNE => false,\n            RealPredicate::RealPredicateTrue => unreachable!(),\n        };\n\n        let cmp = self.context.new_comparison(self.location, op.to_gcc_comparison(), lhs, rhs);","sourceCodeStart":1335,"sourceCodeEnd":1371,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_codegen_gcc/src/builder.rs#L1335-L1371","documentation":"In `fcmp`, the LLVM float predicate `RealPredicate::RealPredicateFalse` (a comparison that is always false) is matched to `unreachable!()`, producing an internal compiler error (ICE) if it is ever reached. The GCC backend assumes rustc constant-folds this degenerate predicate away before codegen; LLVM uses it mostly as a sentinel for folded comparisons, so cg_gcc treats its presence as a frontend contract violation.","triggerScenarios":"rustc lowers a float comparison to `fcmp` with the `RealPredicateFalse` predicate — e.g. a constant-folded dead branch involving float operands, or an `fcmp` that the frontend failed to simplify before reaching the backend.","commonSituations":"cg_gcc built against a rustc version that started emitting this predicate for certain const-evaluated float conditions, or unusual `if false { ... }` guards over float expressions. Reproducible only under the GCC backend.","solutions":["Update rustc_codegen_gcc to match your rustc toolchain version","Simplify or remove the dead/constant-false float comparison in the source","Patch the arm to return a constant false (`self.cx.const_bool(false)`) instead of `unreachable!()`","File an issue with the MIR/IR reproducer"],"exampleFix":"// before\nRealPredicate::RealPredicateFalse => unreachable!(),\n\n// after\nRealPredicate::RealPredicateFalse => return self.cx.const_bool(false),","handlingStrategy":"fallback","validationCode":"// fcmp panics (unreachable!()) on RealPredicate::RealPredicateFalse.\n// 'always false' has no GCC lowering here — emit a constant false instead.\nmatch op {\n    RealPredicate::RealPredicateFalse => {\n        return const_false(builder);\n    }\n    _ => { /* safe to call builder.fcmp(op, lhs, rhs) */ }\n}","typeGuard":null,"tryCatchPattern":"match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {\n    builder.fcmp(op, lhs, rhs)\n})) {\n    Ok(v) => v,\n    Err(_) => const_false(builder),\n}","preventionTips":["Replace `fcmp RealPredicateFalse` with a constant false at the IR-building layer; it never needs a real comparison.","Audit frontends so the always-false float predicate is constant-folded before reaching cg_gcc."],"tags":["rust","codegen","gcc","gccjit","fcmp","float","ice","unreachable"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}