[dcl.attr.noreturn]

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

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

### 9.13.10 Noreturn attribute [dcl.attr.noreturn]

[1](#1)

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

The [*attribute-token*](dcl.attr.grammar#nt:attribute-token "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]") noreturn specifies that a function does not return[.](#1.sentence-1)

No [*attribute-argument-clause*](dcl.attr.grammar#nt:attribute-argument-clause "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]") shall be present[.](#1.sentence-2)

The attribute may be applied to a function or a lambda call operator[.](#1.sentence-3)

The first declaration of a function shall
specify the noreturn attribute if any declaration of that function specifies thenoreturn attribute[.](#1.sentence-4)

If a function is declared with the noreturn attribute in one
translation unit and the same function is declared without the noreturn attribute in another
translation unit, the program is ill-formed, no diagnostic required[.](#1.sentence-5)

[2](#2)

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

If a function f is invoked where f was previously declared with the noreturn attribute and that invocation eventually returns,
the behavior is runtime-undefined[.](#2.sentence-1)

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

The function can
terminate by throwing an exception[.](#2.sentence-2)

â *end note*]

[3](#3)

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

*Recommended practice*: Implementations should issue a
warning if a function marked [[noreturn]] might return[.](#3.sentence-1)

The value of
a [*has-attribute-expression*](cpp.cond#nt:has-attribute-expression "15.2 Conditional inclusion [cpp.cond]") for the noreturn attribute
should be 0 unless the implementation can issue such warnings[.](#3.sentence-2)

[4](#4)

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

[*Example [1](#example-1)*: [[ noreturn ]] void f() {throw "error"; // OK}[[ noreturn ]] void q(int i) { // behavior is undefined if called with an argument <= 0if (i > 0)throw "positive";} â *end example*]
