Skip to content

Commit

Permalink
[except.handle] group all paragraphs on searching for handler
Browse files Browse the repository at this point in the history
This commit moves all of the paragraphs involved in the search for a
handler for an exception into a single logical sequence.

After this change, [except.spec] deals only with specifying the
'noexcept' function decorator and its interaction with the
'noexcept' operator, and contains no text regarding exceptions
themselves.  It might be appropriate to move that subclause into
the [dcl] structure at a future date.
  • Loading branch information
AlisdairM authored and tkoeppe committed Oct 16, 2024
1 parent 8003b62 commit 198e991
Showing 1 changed file with 34 additions and 35 deletions.
69 changes: 34 additions & 35 deletions source/exceptions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,40 @@
handler continues in a dynamically surrounding try block
of the same thread.

\pnum
\indextext{exception handling!terminate called@\tcode{terminate} called}%
\indextext{\idxcode{terminate}!called}%
If the search for a handler
encounters the outermost block of a function with a
non-throwing exception specification,
the function \tcode{std::terminate}\iref{except.terminate} is invoked.
\begin{note}
An implementation is not permitted to reject an expression merely because, when
executed, it throws or might
throw an exception from a function with a non-throwing exception specification.
\end{note}
\begin{example}
\begin{codeblock}
extern void f(); // potentially-throwing

void g() noexcept {
f(); // valid, even if \tcode{f} throws
throw 42; // valid, effectively a call to \tcode{std::terminate}
}
\end{codeblock}
The call to
\tcode{f}
is well-formed despite the possibility for it to throw an exception.
\end{example}

\pnum
If no matching handler is found,
the function \tcode{std::terminate} is invoked;
whether or not the stack is unwound before this invocation of
\tcode{std::terminate}
is \impldef{stack unwinding before invocation of
\tcode{std::terminate}}\iref{except.terminate}.

\pnum
A handler is considered \defnx{active}{exception handling!handler!active} when
initialization is complete for the parameter (if any) of the catch clause.
Expand All @@ -632,14 +666,6 @@
still active is called the
\defnx{currently handled exception}{exception handling!currently handled exception}.

\pnum
If no matching handler is found,
the function \tcode{std::terminate} is invoked;
whether or not the stack is unwound before this invocation of
\tcode{std::terminate}
is \impldef{stack unwinding before invocation of
\tcode{std::terminate}}\iref{except.terminate}.

\pnum
Referring to any non-static member or base class of an object
in the handler for a
Expand Down Expand Up @@ -804,33 +830,6 @@
has a non-throwing exception specification.
\end{example}

\pnum
\indextext{exception handling!terminate called@\tcode{terminate} called}%
\indextext{\idxcode{terminate}!called}%
Whenever an exception is thrown
and the search for a handler\iref{except.handle}
encounters the outermost block of a function with a
non-throwing exception specification,
the function \tcode{std::terminate} is invoked\iref{except.terminate}.
\begin{note}
An implementation is not permitted to reject an expression merely because, when
executed, it throws or might
throw an exception from a function with a non-throwing exception specification.
\end{note}
\begin{example}
\begin{codeblock}
extern void f(); // potentially-throwing

void g() noexcept {
f(); // valid, even if \tcode{f} throws
throw 42; // valid, effectively a call to \tcode{std::terminate}
}
\end{codeblock}
The call to
\tcode{f}
is well-formed despite the possibility for it to throw an exception.
\end{example}

\pnum
An expression $E$ is
\defnx{potentially-throwing}{potentially-throwing!expression} if
Expand Down

0 comments on commit 198e991

Please sign in to comment.