C
The systems language behind operating systems, embedded firmware, cryptography and most language runtimes.
What do you want to prove about your C code?
Where proofs can attach
Toolchains that verify C directly, and those that verify what it compiles to. A proof about compiled code also relies on the compiler that produced it.
- Compiled from Languages that compile to C
- Your code
- Intermediate code Proofs here are about the code the compiler produced
- Machine code Proofs here are about the binary itself
- from C via CompCert verified
- from LLVM IR via LLVM backend (llc) trusted
Verify C directly
Ranked by stage, feature coverage and trust.
| Toolchain | Stage | Trust | Effort | Feature coverage |
|---|---|---|---|---|
| Verified Software Toolchain (Verifiable C) Prove in the Rocq proof assistant that a C program meets its specification; compiled with CompCert, the proof carries down to the assembly code. | Stage 1 · Usable | 4/5 | Interactive | 7/17full, 5 partial |
| CBMC Write a test-like harness for your C code; CBMC checks every execution up to a loop bound, giving a counterexample or a bounded proof. | Stage 1 · Usable | 0/5 | Push-button | 8/17full, 8 partial |
| Frama-C WP Write ACSL contracts and loop invariants as comments in your C code; Frama-C's WP plug-in turns them into proof goals for SMT solvers. | Stage 1 · Usable | 0/5 | Auto-active | 4/17full, 10 partial |
| CN Write ownership and correctness specifications as comments in C code; CN checks them with an SMT solver, or turns them into runtime checks for testing. | Stage 0 · Research | 0/5 | Auto-active | 4/17full, 4 partial |
Verify the compiled code
These prove facts about what the compiler produced, not about your source.
| Toolchain | Stage | Trust | Effort | Path |
|---|---|---|---|---|
| s2n-bignum Prove hand-written x86-64 or Arm64 assembly correct in HOL Light, on the exact bytes of the built object file; used for AWS's cryptography code. | Stage 1 · Usable | 4/5 | Interactive | x86-64 (CompCert, verified) |
| Alive2 Automatically checks that an optimized LLVM IR function still behaves like the original, or shows a counterexample. Loops are checked only up to a set bound. | Stage 1 · Usable | 1/5 | Push-button | LLVM IR (clang, trusted) |
| Islaris Prove Arm or RISC-V machine code correct in Rocq, against the full official Sail ISA models, using Isla symbolic execution and an Iris separation logic. | Stage 0 · Research | 2/5 | Interactive | AArch64 (CompCert, verified) |
| LNSym Prove Armv8 (AArch64) machine code correct in Lean 4 by symbolic simulation over a hand-written model; aimed at AWS-LC cryptographic routines. | Stage 0 · Research | 2/5 | Interactive | AArch64 (CompCert, verified) |
Write new verified code that becomes C
You write in a verification language; its compiler emits the code.
| Toolchain | Stage | Trust | Effort | Path |
|---|---|---|---|---|
| F* with Low* (KaRaMeL to C) Write low-level code in Low*, a C-like subset of F*, prove it safe and correct with F* and Z3, then compile it to readable C with KaRaMeL. | Stage 2 · Production | 1/5 | Auto-active | from F* (Low*): C (KaRaMeL, trusted) |
Feature coverage
Which language features each toolchain handles. Hover or focus a mark for the note and source. Toolchains on compiled code are shown for common features only.
| Feature | Verified Software Toolchain (Verifiable C) | CBMC | Frama-C WP | CN | s2n-bignum via x86-64 | Alive2 via LLVM IR | Islaris via AArch64 | LNSym via AArch64 |
|---|---|---|---|---|---|---|---|---|
| Common features | ||||||||
| Machine integersFixed-width integer arithmetic, overflow and bit operations. | Verified Software Toolchain (Verifiable C), Machine integers: Supported.Signed and unsigned machine integers; signed overflow must be proved absent. Source | CBMC, Machine integers: Supported.Bit-precise machine integers. Source | Frama-C WP, Machine integers: Supported.Machine-integer model by default; overflow and downcast checks are set by kernel -warn options or the RTE plug-in. Source | CN, Machine integers: Supported.Signed overflow and other integer undefined behavior are rejected. Source | s2n-bignum, Machine integers: Unknown. | Alive2, Machine integers: Supported.Integers are encoded as SMT bit-vectors, including the nsw/nuw overflow flags. Source | Islaris, Machine integers: Unknown. | LNSym, Machine integers: Unknown. |
| Floating pointIEEE 754 floating-point arithmetic, including rounding and NaNs. | Verified Software Toolchain (Verifiable C), Floating point: Supported.Uses CompCert's IEEE 754 model. The LAProof work verified a floating-point sparse matrix-vector multiply in C with VST, including accuracy bounds. Source | CBMC, Floating point: Supported.Bit-accurate IEEE 754 for float and double. The math library has very limited support for elementary functions such as sin or exp. Source | Frama-C WP, Floating point: Partial.The default float model follows IEEE 754 and is sound, but the manual says automated provers give very little support for proving float properties. A "real" model exists but is unsound. Source | CN, Floating point: Not supported.The type checker reports floats as unsupported. Source | s2n-bignum, Floating point: Unknown. | Alive2, Floating point: Partial.IEEE-754 operations map to SMT floating-point theory (half, bfloat, float, double, fp128). Not supported: x86 80-bit and PowerPC double-double types. The 2021 paper notes that LLVM's frem rounds differently from SMT's remainder. Source | Islaris, Floating point: Unknown. | LNSym, Floating point: Unknown. |
| Heap and pointersDynamically allocated memory, pointers or references, and aliasing. | Verified Software Toolchain (Verifiable C), Heap and pointers: Supported.Separation logic for pointer data structures; malloc and free have (assumed) specifications. Source | CBMC, Heap and pointers: Supported.malloc/free are modeled; malloc may return NULL by default since 6.0; use-after-free and double free are checked. Source | Frama-C WP, Heap and pointers: Partial.Pointers and aliasing are handled by the Typed memory model, but ACSL clauses for specifying allocation and deallocation are not implemented in WP. Source | CN, Heap and pointers: Supported.Ownership of heap cells is tracked in separation logic. Allocation uses cn_malloc and cn_free_sized in place of malloc and free. Source | s2n-bignum, Heap and pointers: Unknown. | Alive2, Heap and pointers: Partial.Byte-level memory model with blocks and pointer provenance (CAV 2021 encoding). The 2021 paper's stated limitation: it assumes calls do not modify local variables whose address has escaped. Volatile and atomic accesses are unsupported. Source | Islaris, Heap and pointers: Unknown. | LNSym, Heap and pointers: Unknown. |
| Arrays and buffersIndexed memory such as arrays, slices, vectors and byte buffers. | Verified Software Toolchain (Verifiable C), Arrays and buffers: Supported. Source | CBMC, Arrays and buffers: Supported. Source | Frama-C WP, Arrays and buffers: Supported. Source | CN, Arrays and buffers: Supported.Iterated ownership over array ranges, with automatic inference for common access patterns. Source | s2n-bignum, Arrays and buffers: Unknown. | Alive2, Arrays and buffers: Supported.Memory blocks are modeled as SMT arrays of bytes, so arrays and buffers are supported. Source | Islaris, Arrays and buffers: Unknown. | LNSym, Arrays and buffers: Unknown. |
| LoopsUnbounded loops, which need invariants or bounds to verify. | Verified Software Toolchain (Verifiable C), Loops: Supported.Loops are verified with user-written loop invariants. Source | CBMC, Loops: Partial.Loops are unrolled up to a bound. Unwinding assertions (on by default since 6.0) fail if the bound is too small, so a passing run is a proof for all executions. Loops without a small bound need loop contracts (goto-instrument --apply-loop-contracts) for an unbounded proof. Source | Frama-C WP, Loops: Supported.Needs a loop invariant (and a variant for termination) for each loop. Loops built with goto are not supported. Source | CN, Loops: Partial.Loop invariants can be given only on for and while loops. Source | s2n-bignum, Loops: Unknown. | Alive2, Loops: Partial.Loops are unrolled up to a bound (-src-unroll and -tgt-unroll). The default bound is 0: any jump back to an already visited block is cut, so only paths that never repeat a loop body are compared. Bugs that need more iterations are missed. Source | Islaris, Loops: Unknown. | LNSym, Loops: Unknown. |
| RecursionFunctions that call themselves, directly or through others. | Verified Software Toolchain (Verifiable C), Recursion: Supported. Source | CBMC, Recursion: Partial.Recursion is unrolled up to the bound like loops; function contracts can replace recursive calls. Source | Frama-C WP, Recursion: Supported.Recursive functions need a decreases clause when termination is required. Source | CN, Recursion: Supported.Recursive C functions are checked against their specifications. Recursive specification functions are not unfolded automatically; you unfold them or state lemmas by hand. Source | s2n-bignum, Recursion: Unknown. | Alive2, Recursion: Partial.Each function is checked on its own, and calls (recursive or not) are treated as calls to an unknown function. Transformations that change behavior across function boundaries are not supported. Source | Islaris, Recursion: Unknown. | LNSym, Recursion: Unknown. |
| Higher-order codeFunction pointers, closures and callbacks. | Verified Software Toolchain (Verifiable C), Higher-order code: Supported.Function pointers are supported; the manual shows object-oriented C with function pointers (progs/verif_object.v, progs/verif_message.v). Source | CBMC, Higher-order code: Supported.Calls through function pointers become a case split over all functions of a matching type; every possible target must be in the model. Source | Frama-C WP, Higher-order code: Partial.A function pointer must be provably equal to one of a finite set of known functions (ACSL calls extension); function contracts cannot yet be passed through pointers. Source | CN, Higher-order code: Partial.The test suite checks calls through function pointers to known functions; the tutorial does not cover them. Source | s2n-bignum, Higher-order code: Unknown. | Alive2, Higher-order code: Partial.Current code translates indirect calls through function pointers as calls to unknown functions. The 2021 paper still listed function pointers as unsupported. No source found on how precisely the target function is tracked. Source | Islaris, Higher-order code: Unknown. | LNSym, Higher-order code: Unknown. |
| Threads and shared memoryConcurrent threads with locks, atomics or message passing. | Verified Software Toolchain (Verifiable C), Threads and shared memory: Partial.Locks and sequentially consistent atomics only; no relaxed atomics. Source | CBMC, Threads and shared memory: Partial.Bounded exploration of thread interleavings only; no unbounded proofs for concurrent code. Source | Frama-C WP, Threads and shared memory: Not supported.No model of threads or shared-memory concurrency in WP. Source | CN, Threads and shared memory: Not supported.Not supported; locks had to be commented out in the pKVM case study. Source | s2n-bignum, Threads and shared memory: Unknown. | Alive2, Threads and shared memory: Not supported.Atomic instructions and fences are rejected as unsupported. Source | Islaris, Threads and shared memory: Unknown. | LNSym, Threads and shared memory: Unknown. |
| I/O and system callsFiles, network, system calls and foreign-function calls. | Verified Software Toolchain (Verifiable C), I/O and system calls: Partial.Calls to external functions (system calls, I/O) are given specifications that are assumed, not proved. Source | CBMC, I/O and system calls: Partial.Many POSIX and C library calls have built-in models that mostly return nondeterministic values. Since 6.0 a call to a function with no body fails verification unless you add a stub. Source | Frama-C WP, I/O and system calls: Partial.I/O and system calls are described only by ACSL contracts in Frama-C's bundled libc, which are assumed, not proved, and cover a subset of POSIX. Source | CN, I/O and system calls: Unknown.No documentation found on specifying I/O or system calls. | s2n-bignum, I/O and system calls: Unknown. | Alive2, I/O and system calls: Partial.External calls are modeled as unknown functions that may change any memory. The 2021 paper names missing semantics for some string and I/O library functions as a common reason functions were skipped. Source | Islaris, I/O and system calls: Unknown. | LNSym, I/O and system calls: Unknown. |
| Standard librarySpecifications or models for the language's standard library. | Verified Software Toolchain (Verifiable C), Standard library: Partial.Ships assumed specifications for malloc, free, exit and a few others; the manual says their implementations are not proved against them. Other library functions need your own specifications. Source | CBMC, Standard library: Partial.CBMC ships models for parts of the C library (string, stdlib, stdio, pthread and others); coverage is not complete and the math library is limited. Source | Frama-C WP, Standard library: Partial.Frama-C bundles a libc with ACSL specifications that the user manual calls incomplete and part of the trusted computing base. Source | CN, Standard library: Partial.The tutorial covers allocation (cn_malloc, cn_free_sized). No general specifications of the C standard library were found. Source | s2n-bignum, Standard library: Unknown. | Alive2, Standard library: Partial.As of the 2021 paper, 117 C library functions had special semantics, some only partly. Others are treated as unknown calls. Source | Islaris, Standard library: Unknown. | LNSym, Standard library: Unknown. |
| C-specific features | ||||||||
| Pointer casts and provenanceCasting between pointers and integers, pointer arithmetic across objects. | Verified Software Toolchain (Verifiable C), Pointer casts and provenance: Not supported.The manual lists "no casting between integers and pointers" as a restriction of Verifiable C. Source | CBMC, Pointer casts and provenance: Partial.Pointers are (object, offset) pairs. The manual says converting a pointer to an integer is not supported, and integers cast to pointers are NULL or point into a special memory-mapped I/O region. Pointers to different objects are always treated as different, which the manual calls not sound. Source | Frama-C WP, Pointer casts and provenance: Partial.The default Typed model forbids casts between unrelated pointer types (for example reading an int through a char pointer). The option for unlimited casts is unsound; the byte-level model is experimental. Source | CN, Pointer casts and provenance: Partial.Uses the VIP provenance model, which allows integer-pointer casts. The repo's VIP test notes list round-trip casts and provenance through bytes as still to do. Source | · | · | · | · |
| Unions and type punningReading a value through a different type than it was written with. | Verified Software Toolchain (Verifiable C), Unions and type punning: Partial.Unions are supported. Reading a different member than the one written works only in special cases: same representation, or numeric members of the same size (manual chapter on union casting). Source | CBMC, Unions and type punning: Supported.Byte-level memory model; reading a union through another member (including float/integer punning) is covered by the regression suite. Source | Frama-C WP, Unions and type punning: Partial.The manual lists bytes, unions and casts as a hard open limitation; only the experimental Bytes and Region models give byte-level access. Source | CN, Unions and type punning: Not supported.Programs with union types are rejected ("unsupported union types"). Source | · | · | · | · |
| Bit-fieldsStruct members narrower than a byte. | Verified Software Toolchain (Verifiable C), Bit-fields: Not supported.The manual lists "no bitfields in structs" as a restriction, even though CompCert itself supports them. Source | CBMC, Bit-fields: Supported. Source | Frama-C WP, Bit-fields: Unknown.The WP manual does not discuss bit-fields. | CN, Bit-fields: Not supported.The Cerberus front end that CN uses rejects bit-fields as not yet supported. Source | · | · | · | · |
| Variadic functionsFunctions such as printf that take a variable number of arguments. | Verified Software Toolchain (Verifiable C), Variadic functions: Partial.Variadic functions cannot be verified. There is limited, undocumented support for calling printf and fprintf. Source | CBMC, Variadic functions: Supported. Source | Frama-C WP, Variadic functions: Partial.The Variadic plug-in (on by default) rewrites variadic functions and calls into fixed-argument ones; printf/scanf calls with a non-constant format string are not translated. Source | CN, Variadic functions: Not supported.Variadic functions are rejected as unsupported. Source | · | · | · | · |
| setjmp / longjmpNon-local jumps out of nested calls. | Verified Software Toolchain (Verifiable C), setjmp / longjmp: Not supported.CompCert, whose semantics VST uses, treats setjmp and longjmp as ordinary functions and advises against using them. Source | CBMC, setjmp / longjmp: Not supported.The built-in longjmp model is a failing assertion ("longjmp requires instrumentation"), so code that reaches longjmp cannot be verified as is. Source | Frama-C WP, setjmp / longjmp: Not supported.A 2024 Thales/CEA presentation on WP lists setjmp/longjmp among C features still to be handled. Source | CN, setjmp / longjmp: Not supported.Not supported by the underlying Cerberus semantics. Source | · | · | · | · |
| volatile and MMIOMemory-mapped device registers and volatile accesses. | Verified Software Toolchain (Verifiable C), volatile and MMIO: Unknown.The manual does not describe how volatile accesses are verified. | CBMC, volatile and MMIO: Partial.Memory-mapped I/O regions must be declared with __CPROVER_allocated_memory, and device behavior must be modeled by hand (for example by making reads nondeterministic). Source | Frama-C WP, volatile and MMIO: Partial.By default a volatile read gives an arbitrary value and a write is treated as an assigns clause; device behavior is not modeled. Source | CN, volatile and MMIO: Not supported.The underlying Cerberus semantics does not model volatile beyond syntax checks. Source | · | · | · | · |
| Inline assemblyAssembly code embedded in C functions. | Verified Software Toolchain (Verifiable C), Inline assembly: Not supported.No documented support in VST. CompCert turns asm statements off by default and warns that they can break its guarantees. Source | CBMC, Inline assembly: Partial.Only a few x86 and Arm instructions (fences, xchg, FPU control word) are translated. Other inline assembly is dropped without a warning, so its effects are silently ignored. Source | Frama-C WP, Inline assembly: Partial.For extended GNU asm, Frama-C generates assigns clauses from the output operands; what the assembly computes is not modeled and must be specified by hand. Source | CN, Inline assembly: Not supported.Not supported by the underlying Cerberus semantics. Source | · | · | · | · |
Supported Partial Not supported Unknown
Formal semantics of C
Models that proofs about C can be stated against. See formal semanticsFormal semantics. A precise, mathematical definition of what programs in a language do..
- Cerberus C semantics Stage 1 · Validated
An executable semantics of a large part of ISO C11 that explores all behaviors a small C program may have, including pointer provenance. CN is built on it.
- CompCert C and Clight semantics Stage 0 · Mechanized
The formal semantics of C, written in Rocq, that the CompCert compiler is proved correct against. VST proves programs against its Clight part.
Compilers from C
What each compilation step preserves, and whether it is proved.
| To | Via | Assurance | What does not carry over |
|---|---|---|---|
| LLVM IR | clang | trusted | Source-level types and specifications. The line between defined and undefined behavior: clang may already have relied on undefined behavior when it emitted the IR. |
| x86-64 | CompCert | verified | Specifications stay at the C level; the proof covers the CompCert C subset only. CompCert's proof covers compilation to assembly; assembling and linking are outside it. |
| AArch64 | CompCert | verified | Specifications stay at the C level; the proof covers the CompCert C subset only. CompCert's proof covers compilation to assembly; assembling and linking are outside it. |
| RISC-V | CompCert | verified | Specifications stay at the C level; the proof covers the CompCert C subset only. CompCert's proof covers compilation to assembly; assembling and linking are outside it. |