From b1a3b7b842be4553bb895b7275764771fa5c1b6c Mon Sep 17 00:00:00 2001 From: jberne4 Date: Sat, 21 Nov 2026 21:26:56 -0500 Subject: [PATCH 1/2] P4451R2 Early Adoption of an Always-Enforced Label --- source/basic.tex | 37 +++++++++++++++++++++++++++++++++++-- source/declarations.tex | 9 +++++++-- source/preprocessor.tex | 2 +- source/statements.tex | 2 +- source/support.tex | 11 ++++++++--- 5 files changed, 52 insertions(+), 9 deletions(-) diff --git a/source/basic.tex b/source/basic.tex index 2499c57ed9..8f50e47b10 100644 --- a/source/basic.tex +++ b/source/basic.tex @@ -7822,6 +7822,28 @@ if a \grammarterm{result-name-introducer}\iref{dcl.contract.res} has been specified. \end{note} +\rSec2[basic.contract.control]{Control} + +\indextext{contract assertion!control}% + +\begin{bnf} +\nontermdef{assertion-control-specifier}\br + \terminal{<} id-expression \terminal{>} +\end{bnf} + +\pnum +The optional \grammarterm{assertion-control-specifier} of a +\grammarterm{precondition-specifier}, \grammarterm{postcondition-specifier}, +or \grammarterm{assertion-statement} indicates that the +introduced contract assertion is a \defnadj{terminating}{contract assertion}. + +\pnum +The \grammarterm{id-expression} +shall not be +type-dependent or value-dependent and +shall denote +\tcode{std::con\-tracts::con\-trols::enforced}\iref{contracts.syn}. + \rSec2[basic.contract.eval]{Evaluation} \pnum @@ -7841,7 +7863,11 @@ It is \impldef{evaluation semantic used for the evaluation of a contract assertion} which evaluation semantic is used -for any given evaluation of a contract assertion. +for any given evaluation of a contract assertion; +the evaluation semantic +used for the evaluation +of a terminating contract assertion +is a terminating semantic. \begin{note} The range and flexibility of available choices of evaluation semantics depends on the implementation @@ -7850,12 +7876,19 @@ for different evaluations of the same contract assertion, including evaluations during constant evaluation. \end{note} +\begin{note} +The notional evaluation of a contract assertion +to determine if a variable is constant-initializable +is always performed with the ignore evaluation semantic\iref{expr.const.init}. +\end{note} \pnum \recommended An implementation should provide the option to translate a program -such that all evaluations of contract assertions use the ignore semantic +such that all evaluations of contract assertions +that are not terminating contract assertions +use the ignore semantic as well as the option to translate a program such that all evaluations of contract assertions use the enforce semantic. diff --git a/source/declarations.tex b/source/declarations.tex index 79d94c5019..e91c3e139a 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -4675,12 +4675,13 @@ \begin{bnf} \nontermdef{precondition-specifier}\br - \keyword{pre} \opt{attribute-specifier-seq} \terminal{(} conditional-expression \terminal{)} + \keyword{pre} \opt{assertion-control-specifier} \opt{attribute-specifier-seq} \terminal{(} conditional-expression \terminal{)} \end{bnf} \begin{bnf} \nontermdef{postcondition-specifier}\br - \keyword{post} \opt{attribute-specifier-seq} \terminal{(} \opt{result-name-introducer} conditional-expression \terminal{)} + \keyword{post} \opt{assertion-control-specifier} \opt{attribute-specifier-seq} \br + \bnfindent \terminal{(} \opt{result-name-introducer} conditional-expression \terminal{)} \end{bnf} \pnum @@ -4761,6 +4762,10 @@ if \begin{itemize} \item +both $C_1$ and $C_2$ +have \grammarterm{assertion-control-specifier}s +or neither does, +\item their predicates $P_1$ and $P_2$ would satisfy the one-definition rule\iref{basic.def.odr} if placed in function definitions on diff --git a/source/preprocessor.tex b/source/preprocessor.tex index 7ddec0a17e..e82e31f287 100644 --- a/source/preprocessor.tex +++ b/source/preprocessor.tex @@ -2421,7 +2421,7 @@ \defnxname{cpp_constexpr_in_decltype} & \tcode{201711L} \\ \rowsep \defnxname{cpp_constexpr_virtual_inheritance} & \tcode{202506L} \\ \rowsep \defnxname{cpp_constinit} & \tcode{201907L} \\ \rowsep -\defnxname{cpp_contracts} & \tcode{202606L} \\ \rowsep +\defnxname{cpp_contracts} & \tcode{202611L} \\ \rowsep \defnxname{cpp_decltype} & \tcode{200707L} \\ \rowsep \defnxname{cpp_decltype_auto} & \tcode{201304L} \\ \rowsep \defnxname{cpp_deduction_guides} & \tcode{202207L} \\ \rowsep diff --git a/source/statements.tex b/source/statements.tex index 846b203c04..2b2d3b0e67 100644 --- a/source/statements.tex +++ b/source/statements.tex @@ -1240,7 +1240,7 @@ \begin{bnf} \nontermdef{assertion-statement}\br - \terminal{contract_assert} \opt{attribute-specifier-seq} \terminal{(} conditional-expression \terminal{)} \terminal{;} + \terminal{contract_assert} \opt{assertion-control-specifier} \opt{attribute-specifier-seq} \terminal{(} conditional-expression \terminal{)} \terminal{;} \end{bnf} \pnum diff --git a/source/support.tex b/source/support.tex index 759c5fe3d2..549fd873fd 100644 --- a/source/support.tex +++ b/source/support.tex @@ -613,7 +613,7 @@ #define @\defnlibxname{cpp_lib_containers_ranges}@ 202202L // also in \libheader{vector}, \libheader{list}, \libheader{forward_list}, \libheader{map}, \libheader{set}, \libheader{unordered_map}, \libheader{unordered_set}, // \libheader{deque}, \libheader{queue}, \libheader{stack}, \libheader{string} -#define @\defnlibxname{cpp_lib_contracts}@ 202502L // freestanding, also in \libheader{contracts} +#define @\defnlibxname{cpp_lib_contracts}@ 202611L // freestanding, also in \libheader{contracts} #define @\defnlibxname{cpp_lib_copyable_function}@ 202306L // also in \libheader{functional} #define @\defnlibxname{cpp_lib_coroutine}@ 201902L // freestanding, also in \libheader{coroutine} #define @\defnlibxname{cpp_lib_counting_scope}@ 202506L // also in \libheader{execution} @@ -4289,8 +4289,9 @@ \rSec2[contracts.syn]{Header \tcode{} synopsis} \pnum -The header \libheader{contracts} defines types -for reporting information about contract violations\iref{basic.contract.eval}. +The header \libheader{contracts} provides facilities +for reporting information about contract violations\iref{basic.contract.eval} +and controlling the behavior of contract assertions\iref{basic.contract.control}. \indexheader{contracts} \indexlibraryglobal{contract_violation}% @@ -4333,6 +4334,10 @@ }; void invoke_default_contract_violation_handler(const contract_violation&); + + namespace controls { + inline constexpr @\unspec@ enforced = @\unspec@; + } } \end{codeblock} From 7d88783493fdd590065a9a08b1e005c057cfcff8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20K=C3=B6ppe?= Date: Sun, 29 Nov 2026 19:50:57 +0000 Subject: [PATCH 2/2] [cpp.predefined] Change __cpp_contracts to "202612L" for P3097R3. Paper P3097R3 was adopted in Brno 2026 for C++29 and changed the __cpp_contracts macro to "202606L". At that point, the first DIS for C++26 retained the previous value "202502L". With the adoption of P4451R2 for the second DIS for C++26 as well as for the C++29 working draft, the value of the macro needs to be changed again, but we need for C++26 to not depend on any material from C++29. We are therefore updating __cpp_contracts as well as __cplusplus to "202611L" for P4451R2, and conformance with P3097R3 in C++29 is now indicated by the value "202612L". --- source/preprocessor.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/preprocessor.tex b/source/preprocessor.tex index e82e31f287..91c2ab225a 100644 --- a/source/preprocessor.tex +++ b/source/preprocessor.tex @@ -2421,7 +2421,7 @@ \defnxname{cpp_constexpr_in_decltype} & \tcode{201711L} \\ \rowsep \defnxname{cpp_constexpr_virtual_inheritance} & \tcode{202506L} \\ \rowsep \defnxname{cpp_constinit} & \tcode{201907L} \\ \rowsep -\defnxname{cpp_contracts} & \tcode{202611L} \\ \rowsep +\defnxname{cpp_contracts} & \tcode{202612L} \\ \rowsep \defnxname{cpp_decltype} & \tcode{200707L} \\ \rowsep \defnxname{cpp_decltype_auto} & \tcode{201304L} \\ \rowsep \defnxname{cpp_deduction_guides} & \tcode{202207L} \\ \rowsep