[dcl.attr.assume]

# 9 Declarations [[dcl]](./#dcl)

## 9.13 Attributes [[dcl.attr]](dcl.attr#assume)

### 9.13.3 Assumption attribute [dcl.attr.assume]

[1](#1)

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

The [*attribute-token*](dcl.attr.grammar#nt:attribute-token "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]") assume may be applied to a null statement;
such a statement is an [*assumption*](#def:assumption "9.13.3 Assumption attribute [dcl.attr.assume]")[.](#1.sentence-1)

An [*attribute-argument-clause*](dcl.attr.grammar#nt:attribute-argument-clause "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]") shall be present and
shall have the form:

( [*conditional-expression*](expr.cond#nt:conditional-expression "7.6.16 Conditional operator [expr.cond]") )

The expression is contextually converted to bool ([[conv.general]](conv.general "7.3.1 General"))[.](#1.sentence-2)

The expression is not evaluated[.](#1.sentence-3)

If the converted expression would evaluate to true at the point where the assumption appears,
the assumption has no effect[.](#1.sentence-4)

Otherwise,
evaluation of the assumption has runtime-undefined behavior[.](#1.sentence-5)

[2](#2)

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

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

The expression is potentially evaluated ([[basic.def.odr]](basic.def.odr "6.3 One-definition rule"))[.](#2.sentence-1)

The use of assumptions is intended to allow implementations
to analyze the form of the expression and
deduce information used to optimize the program[.](#2.sentence-2)

Implementations are not required to deduce
any information from any particular assumption[.](#2.sentence-3)

It is expected that the value of
a [*has-attribute-expression*](cpp.cond#nt:has-attribute-expression "15.2 Conditional inclusion [cpp.cond]") for the assume attribute
is 0 if an implementation does not attempt to deduce
any such information from assumptions[.](#2.sentence-4)

â *end note*]

[3](#3)

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

[*Example [1](#example-1)*: int divide_by_32(int x) {[[assume(x >= 0)]]; return x/32; // The instructions produced for the division// may omit handling of negative values.}int f(int y) {[[assume(++y == 43)]]; // y is not incrementedreturn y; // statement may be replaced with return 42;} â *end example*]
