P4019R0 — constant_assert (12 items) EWG, EWGI
Jonas Persson
This paper proposes a new assertion facility, constant_assert(expr), which is checked at compile time by the optimizer rather than being limited to constant expressions as static_assert is. If the optimizer cannot prove the expression true (and it is not dead code or constant folded away), the program is ill-formed, providing a zero-overhead, UB-free alternative to assert() and [[assume()]] for cases where the optimizer has sufficient knowledge to resolve the condition. The feature is intentionally based on unspecified behavior, as the optimizer's ability to resolve expressions varies by implementation and optimization level.

References — Anthropic Citations API

[1]
"The optimizer has much of the same functionality as a static analysis tools."
[2]
"We already have assert() that verify a statement at runtime. "
[3]
"Then we have static_assert() that check things in at compile time. "
[4]
"if expr is not dead code, not constant folded and do not evaluate to true at code generation phase, the program is ill formed."
[5]
"The part where the compiler figure out if the expression can be resolved at compiler time is not possible to specify."
[6]
"The part where the compiler figure out if the expression can be resolved at compiler time is not possible to specify. "
[6]
"The part where the compiler figure out if the expression can be resolved at compiler time is not possible to specify. "
[7]
"This mean that constant_assert will have to be wrapped and replaced with something else in unoptimized builds."
[8]
"This mean is should strictly follow what the optimizer actually apply to the code. "
[8]
"This mean is should strictly follow what the optimizer actually apply to the code. "
[9]
"Is is suggested that constant_assert is always resolved at the compilation step, and a separate feature is later added for linker resolved assert if needed. "
[10]
"This mean is should strictly follow what the optimizer actually apply to the code. "
[10]
"This mean is should strictly follow what the optimizer actually apply to the code. "
[11]
"What we get is an assert that can prove a lot more than a static_assert(), without the performance overhead and termination risk of assert() and with the same effect on an [[assume()]] without..."
[12]
"But there is one missing to this set. "
Summary: P4019R0 proposes a new assertion construct, constant_assert, that would behave like assert() but be evaluated at compile time when the compiler can resolve the expression, bridging the gap between runtime assert() and static_assert(). All twelve findings are surface-level grammar and typographical errors distributed throughout the paper.
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.