[stmt.contract.assert]

# 8 Statements [[stmt]](./#stmt)

## 8.9 Assertion statement [stmt.contract.assert]

[assertion-statement:](#nt:assertion-statement "8.9 Assertion statement [stmt.contract.assert]")  
contract_assert [*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")opt ( [*conditional-expression*](expr.cond#nt:conditional-expression "7.6.16 Conditional operator [expr.cond]") ) ;

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/statements.tex#L1224)

An [*assertion-statement*](#nt:assertion-statement "8.9 Assertion statement [stmt.contract.assert]") introduces a contract assertion ([[basic.contract]](basic.contract "6.11 Contract assertions"))[.](#1.sentence-1)

The optional [*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]") appertains to the introduced contract assertion[.](#1.sentence-2)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/statements.tex#L1232)

The predicate ([[basic.contract.general]](basic.contract.general "6.11.1 General"))
of an [*assertion-statement*](#nt:assertion-statement "8.9 Assertion statement [stmt.contract.assert]") is its [*conditional-expression*](expr.cond#nt:conditional-expression "7.6.16 Conditional operator [expr.cond]") contextually converted to bool[.](#2.sentence-1)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/statements.tex#L1238)

The evaluation of consecutive [*assertion-statement*](#nt:assertion-statement "8.9 Assertion statement [stmt.contract.assert]")*s* is an evaluation in sequence ([[basic.contract.eval]](basic.contract.eval "6.11.2 Evaluation")) of
the contract assertions introduced
by those [*assertion-statement*](#nt:assertion-statement "8.9 Assertion statement [stmt.contract.assert]")*s*[.](#3.sentence-1)

[*Note [1](#note-1)*:

A sequence of [*assertion-statement*](#nt:assertion-statement "8.9 Assertion statement [stmt.contract.assert]")*s* can thus be repeatedly evaluated as a group[.](#3.sentence-2)

[*Example [1](#example-1)*: int f(int i){contract_assert(i == 0); // #1contract_assert(i >= 0); // #2return 0;}int g = f(0); // can evaluate #1, #2, #1, #2 â *end example*]

â *end note*]
