It's feasible to create no bugs with formal specification and formal verification. For example, with Lean 4, one can add a proof for each array-access-by-index that the index is within the bound of the associated array. Every aspect of the codebase can be subject to formal proofs that are verified by the compiler. See also CompCert and Sel4.