Files
cppdraft_translate/cppdraft/utility/undefined.md
2025-10-25 03:02:53 +03:00

43 lines
1.2 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[utility.undefined]
# 22 General utilities library [[utilities]](./#utilities)
## 22.2 Utility components [[utility]](utility#undefined)
### 22.2.9 Undefined behavior [utility.undefined]
[🔗](#lib:unreachable)
`[[noreturn]] void unreachable();
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L696)
*Preconditions*: false is true[.](#1.sentence-1)
[*Note [1](#note-1)*:
This precondition cannot be satisfied, thus the behavior
of calling unreachable is undefined[.](#1.sentence-2)
— *end note*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L704)
[*Example [1](#example-1)*: int f(int x) {switch (x) {case 0:case 1:return x; default: std::unreachable(); }}int a = f(1); // OK, a has value 1int b = f(3); // undefined behavior — *end example*]
[🔗](#lib:observable_checkpoint)
`void observable_checkpoint() noexcept;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L728)
*Effects*: Establishes an observable checkpoint ([[intro.abstract]](intro.abstract "4.1.2Abstract machine"))[.](#3.sentence-1)