P3977R0 — A New Taxonomy for Contracts (14 items) WG21
Oliver J. Rosten
This paper proposes a richer classification of C++ contracts to address deficiencies in the existing wide/narrow binary taxonomy, which becomes counterintuitive or inapplicable in scenarios involving non-ignorable or unconditionally hardened preconditions. It formalizes the notions of primary and secondary behaviour, primary and secondary domain, and primary and secondary codomain, then introduces eight contract categories: free, disambiguating, lossy, disconnecting, unconditionally hardened, narrow, pathological, and faithful (a union of free and disambiguating). The taxonomy enables precise reasoning about cases such as a function with a precondition that is always enforced, which is neither wide nor narrow under the existing scheme.

References — Anthropic Citations API

[1]
"float sqrt(float) pre (x >= 0);"
[2]
"it is reasonably to assume"
[3]
"First, we need to define delineate different meanings of undefined behaviour."
[4]
"Furthermore, just a erroneous behaviour is well-defined, we also want to capture the case"
[5]
"if is called with a negative argument"
[6]
"The secondary codomain of void abort() pre (false); is the the program aborting. "
[7]
"cannot be classified as other wide or narrow according to the definition of [N3248]."
[8]
"Program execution continues indefinitely without return control to the caller"
[9]
"Unlike, say, dereferencing a null pointer erroneous behaviour is well-defined."
[10]
"Consider everybody’s favourite mathematical function float std::frexp(float num, int* exp); This has a plain-language precondition that the pointer, exp, must be derefenceable. "
[11]
"The next contract definition relaxes the requirement that no elements of the secondary domain map to the primary domain."
[12]
"implementation Freedom & the ABI 6 IV. "
[13]
"Primary and secondary Behaviour 7 V. A Taxonomy for Contracts 10 VI. "
Summary: Proposes a mathematical taxonomy for C++ contracts built on the notions of primary and secondary behaviour, codomains, and function-level correctness classifications, aiming to replace the current wide/narrow contract distinction with a framework that integrates erroneous behaviour and contract annotations.
Pipeline: Discovery (Anthropic Opus + Citations API) → Verification Gate (OpenRouter Opus) → Report Writer (OpenRouter Opus)
Provenance: All references are machine-verified character positions from the Anthropic Citations API — deterministic, exact substrings, not model-generated quotes.