diff --git a/source/basic.tex b/source/basic.tex index 5a3202c96c..25b516de57 100644 --- a/source/basic.tex +++ b/source/basic.tex @@ -6912,8 +6912,8 @@ \rSec3[intro.progress]{Forward progress} \pnum -The implementation may assume that any thread will eventually do one of the -following: +The implementation may assume\ubdef{intro.progress.stops} that any thread +will eventually do one of the following: \begin{itemize} \item terminate, \item invoke the function \tcode{std::this_thread::yield}\iref{thread.thread.this}, diff --git a/source/ub.tex b/source/ub.tex index c248629560..6fd4f1b258 100644 --- a/source/ub.tex +++ b/source/ub.tex @@ -502,6 +502,29 @@ \end{codeblock} \end{example} +\rsec2[ub.intro.progress]{Forward progress} + +\pnum +\ubxref{intro.progress.stops} \\ + +The behavior is undefined if a thread of execution that has not terminated stops +making execution steps. + +\pnum +\begin{example} +\begin{codeblock} +bool stop() { return false; } + +void busy_wait_thread() { + while (!stop()); // undefined behavior, thread makes no progress but the loop +} // is not trivial because `stop()` is not a constant expression + +int main() { + std::thread t(busy_wait_thread); + t.join(); +} +\end{codeblock} +\end{example} \rSec2[ub.basic.start.main]{main function}