# Cerberus C semantics

> 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.

- Kind: formal semantics
- Models: C (ISO C11 (fragment))
- Fragment: A substantial fragment of ISO C11, single-threaded in the base version. Not supported: bit-fields, variable-length arrays, C11 generic selection, C11 character-set types, setjmp/longjmp and signals. Only modeled informally or partly: floating point (float and double via OCaml floats), volatile, restrict and register (syntax checks only), the standard library (an adapted musl libc plus a formal printf). The preprocessor is not modeled; GCC or Clang preprocess the input.
- Written in: Lem (translated to OCaml)
- Available in: —
- Stage: 1 (Validated)
- Licence: open-source, BSD-2-Clause (with listed exceptions)
- Validation: Published test results. Memarian's 2023 thesis reports differential testing against Clang on Csmith programs (1186 of 1192 and 463 of 470 tests agree; the rest time out) and the GCC torture tests (1148 of 1160 supported tests executed correctly, after manual adaptation; 363 tests use unsupported features). The POPL 2019 paper reports earlier GCC torture results (948 of 974) and results on the ITC Toyota benchmark and a pointer-provenance test suite.
- Latest release: main@d6eab7d (2026-11-24) https://github.com/rems-project/cerberus/commits/master
- Used by toolchains: cn

## Stage

**Stage 1: Validated.**

| Stage | Criterion | Met | Evidence / note |
|---|---|---|---|
| 0 | Machine-checked or machine-readable definition | yes | [evidence](https://github.com/rems-project/cerberus) A machine-readable definition in Lem (about 20,000 lines in 2019), compiled to OCaml. It is not available as definitions in a proof assistant. |
| 0 | Fragment and version are stated | yes | [evidence](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-981.pdf) The thesis introduction lists missing and simplified features. |
| 1 | Can be executed or tested | yes | [evidence](https://github.com/rems-project/cerberus#basic-usage) cerberus --exec runs C programs; a web interface explores all allowed behaviors of small tests. |
| 1 | Published results against conformance tests or real implementations | yes | [evidence](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-981.pdf) Chapter 12: Csmith differential testing against Clang and the GCC torture tests. |
| 2 | Adopted by the language or ISA owner, or covers the full current version and tracks new ones | no | [evidence](https://webstore.iec.ch/en/publication/107524) Adopted by the owner: no; full coverage: no; tracks new versions: no. Not an official reference for C. Its authors worked with ISO WG14 on pointer provenance; WG14 has since published ISO/IEC TS 6010:2025, a provenance-aware memory object model for C. Several C11 features are missing (see fragment). No stated policy for following new C standards (C17, C23). |

Missing for Stage 2: Adopted by the language or ISA owner, or covers the full current version and tracks new ones.

## Common features

| Feature | Coverage |
|---|---|
| Machine integers | Supported — Integer undefined behavior is detected. Implementation-defined sizes follow LP64 for testing. ([source](http://www.cl.cam.ac.uk/users/pes20/cerberus/cerberus-popl2019.pdf)) |
| Floating point | Partial — Informal: only float and double, computed with OCaml's floats. Floating-point undefined behavior and the floating-point environment are not modeled. ([source](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-981.pdf)) |
| Heap and pointers | Supported — Memory object models with pointer provenance are the core of the work. ([source](http://www.cl.cam.ac.uk/users/pes20/cerberus/cerberus-popl2019.pdf)) |
| Arrays and buffers | Partial — Variable-length arrays are not supported; flexible array members are supported but need more validation. ([source](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-981.pdf)) |
| Loops | Supported |
| Recursion | Supported |
| Higher-order code | Supported — Function pointers are supported. ([source](http://www.cl.cam.ac.uk/users/pes20/cerberus/cerberus-popl2019.pdf)) |
| Threads and shared memory | Partial — The base semantics is single-threaded. Extensions by collaborators add the C11 concurrency model; Cerberus-BMC handles small concurrent examples. ([source](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-981.pdf)) |
| I/O and system calls | Partial — printf is modeled formally. The 2019 paper notes there is no file system support (for example scanf). ([source](http://www.cl.cam.ac.uk/users/pes20/cerberus/cerberus-popl2019.pdf)) |
| Standard library | Partial — Library headers come from an adapted musl libc, so undefined behavior inside library functions is only detected as far as musl's own code triggers it. ([source](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-981.pdf)) |

## C-specific features

| Feature | Coverage |
|---|---|
| Pointer casts and provenance | Supported — Implements provenance-aware memory models (PNVI variants) including integer-pointer casts. Provenance of sub-objects is not modeled; the thesis calls its semantics an open problem. ([source](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-981.pdf)) |
| Unions and type punning | Partial — Unions and union type punning are modeled. C's effective-type (strict aliasing) rules are not: the model targets code built with -fno-strict-aliasing. ([source](http://www.cl.cam.ac.uk/users/pes20/cerberus/cerberus-popl2019.pdf)) |
| Bit-fields | Not supported — The front end rejects bit-fields as not yet supported. ([source](https://github.com/rems-project/cerberus/blob/master/frontend/model/cabs_to_ail.lem)) |
| Variadic functions | Partial — User-defined variadic functions are supported, but undefined behavior from misusing stdarg.h is not detected. ([source](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-981.pdf)) |
| setjmp / longjmp | Not supported — Non-local jumps (setjmp.h) and signals are not supported. ([source](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-981.pdf)) |
| volatile and MMIO | Not supported — volatile is checked only as syntax; its meaning is not modeled. ([source](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-981.pdf)) |
| Inline assembly | Not supported — Not supported; the thesis lists 26 GCC torture tests excluded for using inline assembly. ([source](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-981.pdf)) |

## Sources
- [Cerberus repository and README](https://github.com/rems-project/cerberus)
- [Cerberus project page](https://www.cl.cam.ac.uk/~pes20/cerberus/)
- [The Cerberus C semantics (Memarian, PhD thesis, UCAM-CL-TR-981, 2023)](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-981.pdf)
- [Exploring C Semantics and Pointer Provenance (POPL 2019)](http://www.cl.cam.ac.uk/users/pes20/cerberus/cerberus-popl2019.pdf)
- [ISO/IEC TS 6010:2025, A provenance-aware memory object model for C](https://webstore.iec.ch/en/publication/107524)
- [Cerberus license](https://github.com/rems-project/cerberus/blob/master/LICENSE)

---
Last checked 2026-11-26. Data: [JSON](/semantics/cerberus.json) · Page: [HTML](/semantics/cerberus/) · Methodology v0.1: [/methodology/](/methodology/) · Corrections: [/contribute/](/contribute/)
