P4019R0 — constant_assert
(12 items)
EWG, EWGI
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.
- Section 1, Introduction — "the same effect on an [[assume()]]" — wrong preposition; should be "the same effect as" to express equivalence. [7] [1]
- Section 1, Introduction — "one missing to this set" — wrong preposition; should be "missing from this set." [8] [2]
- Section 1, Introduction — "a static analysis tools" — article-noun number disagreement; either "a static analysis tool" or "as static analysis tools." [3]
- Section 1, Introduction — "assert() that verify" — subject-verb disagreement; singular subject requires "verifies." [1] [4]
- Section 1, Introduction — "static_assert() that check things in at compile time" — "check" should be "checks" (singular subject) and "in" is a spurious word before "at." [2] [5]
- Section 2.1 — "do not evaluate to true" — "expr" is singular; should be "does not evaluate to true." [6]
- Section 4, Unspecified behaviour — "the compiler figure out" — singular subject requires "figures out." [3] [7]
- Section 4, Unspecified behaviour — "at compiler time" — should be "at compile time"; all other occurrences in the paper use "compile time." [3] [8]
- Section 5, Non optimizing modes — "This mean that" — singular subject requires "This means that." [9]
- Section 6.1, Why not a library function? — "This mean is should strictly follow what the optimizer actually apply" — three errors in one sentence: "mean" -> "means", "is" -> "it", "apply" -> "applies." [4] [6] [10]
- Section 6.2, LTO — "Is is suggested" — duplicated word; should be "It is suggested." [5] [11]
References — Anthropic Citations API
[1]
"The optimizer has much of the same functionality as a static analysis tools."
"The optimizer has much of the same functionality as a static analysis tools."
[2]
"We already have assert() that verify a statement at runtime. "
"We already have assert() that verify a statement at runtime. "
[3]
"Then we have static_assert() that check things in at compile time. "
"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."
"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."
"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. "
"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. "
"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."
"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. "
"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. "
"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. "
"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. "
"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. "
"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..."
"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. "
"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.
Provenance: All references are machine-verified character positions from the Anthropic Citations API — deterministic, exact substrings, not model-generated quotes.