[stmt.pre]

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

## 8.1 Preamble [stmt.pre]

[1](#1)

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

Except as indicated, statements are executed in sequence ([[intro.execution]](intro.execution "6.10.1 Sequential execution"))[.](#1.sentence-1)

[statement:](#nt:statement "8.1 Preamble [stmt.pre]")  
[*labeled-statement*](stmt.label#nt:labeled-statement "8.2 Label [stmt.label]")  
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")opt [*expression-statement*](stmt.expr#nt:expression-statement "8.3 Expression statement [stmt.expr]")  
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")opt [*compound-statement*](stmt.block#nt:compound-statement "8.4 Compound statement or block [stmt.block]")  
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")opt [*selection-statement*](stmt.select.general#nt:selection-statement "8.5.1 General [stmt.select.general]")  
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")opt [*iteration-statement*](stmt.iter.general#nt:iteration-statement "8.6.1 General [stmt.iter.general]")  
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")opt [*expansion-statement*](stmt.expand#nt:expansion-statement "8.7 Expansion statements [stmt.expand]")  
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")opt [*jump-statement*](stmt.jump.general#nt:jump-statement "8.8.1 General [stmt.jump.general]")  
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")opt [*assertion-statement*](stmt.contract.assert#nt:assertion-statement "8.9 Assertion statement [stmt.contract.assert]")  
[*declaration-statement*](stmt.dcl#nt:declaration-statement "8.10 Declaration statement [stmt.dcl]")  
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")opt [*try-block*](except.pre#nt:try-block "14.1 Preamble [except.pre]")

[init-statement:](#nt:init-statement "8.1 Preamble [stmt.pre]")  
[*expression-statement*](stmt.expr#nt:expression-statement "8.3 Expression statement [stmt.expr]")  
[*simple-declaration*](dcl.pre#nt:simple-declaration "9.1 Preamble [dcl.pre]")  
[*alias-declaration*](dcl.pre#nt:alias-declaration "9.1 Preamble [dcl.pre]")

[condition:](#nt:condition "8.1 Preamble [stmt.pre]")  
[*expression*](expr.comma#nt:expression "7.6.20 Comma operator [expr.comma]")  
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")opt [*decl-specifier-seq*](dcl.spec.general#nt:decl-specifier-seq "9.2.1 General [dcl.spec.general]") [*declarator*](dcl.decl.general#nt:declarator "9.3.1 General [dcl.decl.general]") [*brace-or-equal-initializer*](dcl.init.general#nt:brace-or-equal-initializer "9.5.1 General [dcl.init.general]")  
[*structured-binding-declaration*](dcl.pre#nt:structured-binding-declaration "9.1 Preamble [dcl.pre]") [*initializer*](dcl.init.general#nt:initializer "9.5.1 General [dcl.init.general]")

[for-range-declaration:](#nt:for-range-declaration "8.1 Preamble [stmt.pre]")  
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")opt [*decl-specifier-seq*](dcl.spec.general#nt:decl-specifier-seq "9.2.1 General [dcl.spec.general]") [*declarator*](dcl.decl.general#nt:declarator "9.3.1 General [dcl.decl.general]")  
[*structured-binding-declaration*](dcl.pre#nt:structured-binding-declaration "9.1 Preamble [dcl.pre]")

[for-range-initializer:](#nt:for-range-initializer "8.1 Preamble [stmt.pre]")  
[*expr-or-braced-init-list*](dcl.init.general#nt:expr-or-braced-init-list "9.5.1 General [dcl.init.general]")

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 respective statement[.](#1.sentence-2)

See [[dcl.meaning]](dcl.meaning "9.3.4 Meaning of declarators") for the optional [*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]") in a[*for-range-declaration*](#nt:for-range-declaration "8.1 Preamble [stmt.pre]")[.](#1.sentence-3)

[2](#2)

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

A [*substatement*](#def:substatement "8.1 Preamble [stmt.pre]") of a [*statement*](#nt:statement "8.1 Preamble [stmt.pre]") is one of the following:

- [(2.1)](#2.1)

for a [*labeled-statement*](stmt.label#nt:labeled-statement "8.2 Label [stmt.label]"), its [*statement*](#nt:statement "8.1 Preamble [stmt.pre]"),

- [(2.2)](#2.2)

for a [*compound-statement*](stmt.block#nt:compound-statement "8.4 Compound statement or block [stmt.block]"), any [*statement*](#nt:statement "8.1 Preamble [stmt.pre]") of its [*statement-seq*](stmt.block#nt:statement-seq "8.4 Compound statement or block [stmt.block]"),

- [(2.3)](#2.3)

for a [*selection-statement*](stmt.select.general#nt:selection-statement "8.5.1 General [stmt.select.general]"), any of its [*statement*](#nt:statement "8.1 Preamble [stmt.pre]")*s* or [*compound-statement*](stmt.block#nt:compound-statement "8.4 Compound statement or block [stmt.block]")*s* (but not its [*init-statement*](#nt:init-statement "8.1 Preamble [stmt.pre]")),

- [(2.4)](#2.4)

for an [*iteration-statement*](stmt.iter.general#nt:iteration-statement "8.6.1 General [stmt.iter.general]"), its [*statement*](#nt:statement "8.1 Preamble [stmt.pre]") (but not an [*init-statement*](#nt:init-statement "8.1 Preamble [stmt.pre]")), or

- [(2.5)](#2.5)

for an [*expansion-statement*](stmt.expand#nt:expansion-statement "8.7 Expansion statements [stmt.expand]"), its [*compound-statement*](stmt.block#nt:compound-statement "8.4 Compound statement or block [stmt.block]") (but not an [*init-statement*](#nt:init-statement "8.1 Preamble [stmt.pre]"))[.](#2.sentence-1)

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

The [*compound-statement*](stmt.block#nt:compound-statement "8.4 Compound statement or block [stmt.block]") of a [*lambda-expression*](expr.prim.lambda.general#nt:lambda-expression "7.5.6.1 General [expr.prim.lambda.general]") is not a substatement of the [*statement*](#nt:statement "8.1 Preamble [stmt.pre]") (if any)
in which the [*lambda-expression*](expr.prim.lambda.general#nt:lambda-expression "7.5.6.1 General [expr.prim.lambda.general]") lexically appears[.](#2.sentence-2)

â *end note*]

[3](#3)

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

A [*statement*](#nt:statement "8.1 Preamble [stmt.pre]") S1 [*encloses*](#def:enclosing_statement "8.1 Preamble [stmt.pre]") a [*statement*](#nt:statement "8.1 Preamble [stmt.pre]") S2 if

- [(3.1)](#3.1)

S2 is a substatement of S1,

- [(3.2)](#3.2)

S1 is a [*selection-statement*](stmt.select.general#nt:selection-statement "8.5.1 General [stmt.select.general]"), [*iteration-statement*](stmt.iter.general#nt:iteration-statement "8.6.1 General [stmt.iter.general]"), or [*expansion-statement*](stmt.expand#nt:expansion-statement "8.7 Expansion statements [stmt.expand]"),
 and S2 is the [*init-statement*](#nt:init-statement "8.1 Preamble [stmt.pre]") of S1,

- [(3.3)](#3.3)

S1 is a [*try-block*](except.pre#nt:try-block "14.1 Preamble [except.pre]") and S2 is its [*compound-statement*](stmt.block#nt:compound-statement "8.4 Compound statement or block [stmt.block]") or
 any of the [*compound-statement*](stmt.block#nt:compound-statement "8.4 Compound statement or block [stmt.block]")*s* of
 its [*handler*](except.pre#nt:handler "14.1 Preamble [except.pre]")*s*, or

- [(3.4)](#3.4)

S1 encloses a statement S3 and S3 encloses S2[.](#3.sentence-1)

A statement S1 is[*enclosed by*](#def:enclosed_by_statement "8.1 Preamble [stmt.pre]") a statement S2 ifS2 encloses S1[.](#3.sentence-2)

[4](#4)

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

The rules for [*condition*](#nt:condition "8.1 Preamble [stmt.pre]")*s* apply both
to [*selection-statement*](stmt.select.general#nt:selection-statement "8.5.1 General [stmt.select.general]")*s* ([[stmt.select]](stmt.select "8.5 Selection statements")) and
to the for and while statements ([[stmt.iter]](stmt.iter "8.6 Iteration statements"))[.](#4.sentence-1)

If a [*structured-binding-declaration*](dcl.pre#nt:structured-binding-declaration "9.1 Preamble [dcl.pre]") appears in a [*condition*](#nt:condition "8.1 Preamble [stmt.pre]"),
the [*condition*](#nt:condition "8.1 Preamble [stmt.pre]") is a structured binding declaration ([[dcl.pre]](dcl.pre "9.1 Preamble"))[.](#4.sentence-2)

A [*condition*](#nt:condition "8.1 Preamble [stmt.pre]") that is
neither an [*expression*](expr.comma#nt:expression "7.6.20 Comma operator [expr.comma]") nor a structured binding declaration
is a declaration ([[dcl]](dcl "9 Declarations"))[.](#4.sentence-3)

The [*declarator*](dcl.decl.general#nt:declarator "9.3.1 General [dcl.decl.general]") shall not
specify a function or an array[.](#4.sentence-4)

The [*decl-specifier-seq*](dcl.spec.general#nt:decl-specifier-seq "9.2.1 General [dcl.spec.general]") shall not
define a class or enumeration[.](#4.sentence-5)

If the auto [*type-specifier*](dcl.type.general#nt:type-specifier "9.2.9.1 General [dcl.type.general]") appears in
the [*decl-specifier-seq*](dcl.spec.general#nt:decl-specifier-seq "9.2.1 General [dcl.spec.general]"),
the type of the identifier being declared is deduced from the initializer as described in [[dcl.spec.auto]](dcl.spec.auto "9.2.9.7 Placeholder type specifiers")[.](#4.sentence-6)

[5](#5)

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

The [*decision variable*](#def:variable,decision "8.1 Preamble [stmt.pre]") of a [*condition*](#nt:condition "8.1 Preamble [stmt.pre]") that is neither an [*expression*](expr.comma#nt:expression "7.6.20 Comma operator [expr.comma]") nor a structured binding declaration
is the declared variable[.](#5.sentence-1)

The decision variable of a [*condition*](#nt:condition "8.1 Preamble [stmt.pre]") that is a structured binding declaration is specified in [[dcl.struct.bind]](dcl.struct.bind "9.7 Structured binding declarations")[.](#5.sentence-2)

[6](#6)

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

The value of a [*condition*](#nt:condition "8.1 Preamble [stmt.pre]") that is not an [*expression*](expr.comma#nt:expression "7.6.20 Comma operator [expr.comma]") in a statement other than a switch statement is the value of the
decision variable
contextually converted to bool ([[conv]](conv "7.3 Standard conversions"))[.](#6.sentence-1)

If that
conversion is ill-formed, the program is ill-formed[.](#6.sentence-2)

The value of a[*condition*](#nt:condition "8.1 Preamble [stmt.pre]") that is an expression is the value of the
expression, contextually converted to bool for statements other
than switch;
if that conversion is ill-formed, the program is
ill-formed[.](#6.sentence-3)

The value of the condition will be referred to as simply
âthe conditionâ where the usage is unambiguous[.](#6.sentence-4)

[7](#7)

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

If a [*condition*](#nt:condition "8.1 Preamble [stmt.pre]") can be syntactically resolved
as either an expression or a declaration,
it is interpreted as the latter[.](#7.sentence-1)

[8](#8)

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

In the [*decl-specifier-seq*](dcl.spec.general#nt:decl-specifier-seq "9.2.1 General [dcl.spec.general]") of a [*condition*](#nt:condition "8.1 Preamble [stmt.pre]") or of a [*for-range-declaration*](#nt:for-range-declaration "8.1 Preamble [stmt.pre]"),
including that of any [*structured-binding-declaration*](dcl.pre#nt:structured-binding-declaration "9.1 Preamble [dcl.pre]") of
the [*condition*](#nt:condition "8.1 Preamble [stmt.pre]"),
each[*decl-specifier*](dcl.spec.general#nt:decl-specifier "9.2.1 General [dcl.spec.general]") shall be either a [*type-specifier*](dcl.type.general#nt:type-specifier "9.2.9.1 General [dcl.type.general]") or constexpr[.](#8.sentence-1)

The [*decl-specifier-seq*](dcl.spec.general#nt:decl-specifier-seq "9.2.1 General [dcl.spec.general]") of a [*for-range-declaration*](#nt:for-range-declaration "8.1 Preamble [stmt.pre]") shall not define a class or enumeration[.](#8.sentence-2)
