{"record":{"id":"b5131a9c43f5d0bb","repo":"rust-lang/rust","slug":"not-implemented-b5131a","errorCode":null,"errorMessage":"not implemented","messagePattern":"not implemented","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/rustc_codegen_gcc/src/consts.rs","lineNumber":96,"sourceCode":"            .global_set_readonly();\n        self.const_globals.borrow_mut().insert(cv, global_value);\n        global_value\n    }\n\n    fn codegen_static(&mut self, def_id: DefId) {\n        let attrs = self.tcx.codegen_fn_attrs(def_id);\n\n        let Ok((value, alloc)) = codegen_static_initializer(self, def_id) else {\n            // Error has already been reported\n            return;\n        };\n        let alloc = alloc.inner();\n\n        // boolean SSA values are i1, but they have to be stored in i8 slots,\n        // otherwise some LLVM optimization passes don't work as expected\n        let val_llty = self.val_ty(value);\n        if val_llty == self.type_i1() {\n            unimplemented!();\n        };\n\n        let is_thread_local = attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL);\n        let global = self.get_static_inner(def_id, val_llty);\n\n        #[cfg(feature = \"master\")]\n        if global.to_rvalue().get_type() != val_llty {\n            global.to_rvalue().set_type(val_llty);\n        }\n\n        // NOTE: Alignment from attributes has already been applied to the allocation.\n        set_global_alignment(self, global, alloc.align);\n\n        global.global_set_initializer_rvalue(value);\n\n        // As an optimization, all shared statics which do not have interior\n        // mutability are placed into read-only memory.\n        if alloc.mutability.is_not() {","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/compiler/rustc_codegen_gcc/src/consts.rs#L78-L114","documentation":"In codegen_static (consts.rs:96), the backend checks whether the static's value type is i1 (a single boolean bit, the LLVM representation of bool SSA values). If so it calls unimplemented!() because the GCC path for storing a boolean SSA value into a static's storage slot is not finished — the FIXME comment above notes that i1 values must be widened to i8 for some LLVM optimization passes, but the GCC backend has not implemented that widening for statics.","triggerScenarios":"Defining a static whose initializer value lowers to an i1 type — e.g. static BOOL: bool = true; or any static of type bool where the codegen value is the i1 representation rather than i8. Compiling such a crate with the GCC backend reaches consts.rs:96 and panics.","commonSituations":"Defining static bools or statics of types whose initializer is reduced to an i1 constant; common in config flags, feature flags, or FFI bool globals compiled under the GCC backend.","solutions":["Switch the affected crate to the LLVM backend.","Change the static's type from bool to a type that lowers to i8/u8 (e.g. static FLAG: u8 = 1;) and convert at use sites.","If you control a fork, widen the i1 value to i8 before storage in codegen_static, mirroring the LLVM backend.","Avoid static bools in code compiled with rustc_codegen_gcc until the gap is closed upstream."],"exampleFix":"// before: static bool (panics in gcc backend at consts.rs:96)\nstatic ENABLED: bool = true;\n\n// after: store as u8, convert at use sites\nstatic ENABLED: u8 = 1;\n// at use site:\nlet enabled = ENABLED != 0;","handlingStrategy":"validation","validationCode":"# Reject static bools in code meant for the gcc backend.\nif grep -rnE '^\\s*static\\s+[A-Z_]+\\s*:\\s*bool' src/; then\n  echo 'static bool is unsupported by rustc_codegen_gcc (consts.rs:96); use u8 or compile with LLVM.'\n  exit 1\nfi","typeGuard":"// Represent boolean globals as u8 to avoid the i1 static codegen path.\nstruct Flag(const u8);\nimpl Flag {\n    const TRUE: u8 = 1;\n    const FALSE: u8 = 0;\n}\nstatic ENABLED: u8 = Flag::TRUE; // caller checks != 0","tryCatchPattern":"if ! RUSTFLAGS=\"-Zcodegen-backend=gcc\" cargo build 2>err.log; then\n  grep -q 'not implemented' err.log && { echo 'static bool gap; using LLVM'; cargo build; }\nfi","preventionTips":["Do not declare static bools in crates compiled by the gcc backend.","Use static u8 (= 0/1) and convert at use sites.","Run a pre-build grep for `static ... : bool` before enabling the gcc backend."],"tags":["rust","rustc-codegen-gcc","statics","bool","codegen","consts"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}