The assume directive provides invariants to the implementation that may be used for optimization purposes.
If the invariants do not hold at runtime, the behavior is unspecified. The assume directive is an informational
where clause is either assumption-clause or a clause of the form ext_implementation-defined-assumption
for an implementation-defined assumption clause, and where assumption-clause is one of the
The assume directive gives the implementation additional information about the expected properties of the
program that can optionally be used to optimize the implementation. An implementation may ignore this
information without altering the behavior of the program.
The scope of the assumes directive is the code executed and reached from the current compilation unit.
The scope of the assume directive is the code executed in the corresponding region or in any region that is
nested in the corresponding region.
The scope of the beginassumes directive is the code that is executed and reached from any of the
declared functions in declaration-definition-seq.
The absent and contains clauses accept a list of one or more directive names that may match a
construct that is encountered within the scope of the directive. An encountered construct matches the
directive name if it has the same name as one of the specified directive names or if it is a combined or
composite construct for which a constituent construct has the same name as one of the specified directive
When the absent clause appears on an assume directive, the application guarantees that no constructs that
match a listed directive name are encountered in the scope of the assume directive.
When the contains clause appears on an assume directive, the application provides a hint that constructs
that match the listed directive names are likely to be encountered in the scope of the assume
When the holds clause appears on an assume directive, the application guarantees that the listed
expression evaluates to true in the scope of the directive. The effect of the clause does not include an
evaluation of the expression that is observable.
The no_openmp clause guarantees that no OpenMP related code is executed in the scope of the
The no_openmp_routines clause guarantees that no explicit OpenMP runtime library calls are
executed in the scope of the directive.
The no_parallelism clause guarantees that no OpenMP tasks (explicit or implicit) will be generated
and that no SIMD constructs will be executed in the scope of the directive.
Implementers are allowed to include additional implementation-defined assumption clauses. All
implementation-defined assumptions should begin with ext_. Assumption names that do not start with
ext_ are reserved.
The restrictions to the assume directive are as follows:
A directive-name that appears in an absent or contains clause may not be a directive that is not
associated with the execution of user or implementation code, i.e., a nothing directive, a declarative
directive, a metadirective, or a loop transformation directive.
∙ The assumes directive may only appear at file scope.
∙ The assumes directive may only appear at file or namespace scope.
∙ The assumes directive may only appear in the specification part of a module or subprogram, after any
USE statement, any IMPORT statement, and any IMPLICIT statement.