Skip to content

Commit

Permalink
[except.uncaught] Tidy the specification for uncaught exceptions
Browse files Browse the repository at this point in the history
Several concurrent fixes.  First include the normative wording
that 'uncaught_exceptions' returns the number of uncaught
exceptions *on the current thread*.  This wording is present
in the core language.

Then move the core wording for when an exception is uncaught
directly into the text that talks about caught and uncaught
exceptions.  In the process, turn the reference to
 into a note, so that there is only
one normative specification.

Finally, remove [except.uncaught] as it is now empty, and add
the missing descriptive sentence to the intro paragraph of
[except.special.general].  This happens to produce quite a
pleasing page-break, but that is just luck, not design.
  • Loading branch information
AlisdairM committed Oct 1, 2024
1 parent 2b3e09e commit a8257b4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
44 changes: 24 additions & 20 deletions source/exceptions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,30 @@
it is rethrown.
\end{note}

\pnum
An exception is considered uncaught
after completing the initialization of the exception object\iref{except.throw}

Check failure on line 332 in source/exceptions.tex

View workflow job for this annotation

GitHub Actions / Run checks on Linux

exceptions.tex:332:cross-reference to its own section: section self-reference to [except.throw]
until completing the activation of a handler for the exception\iref{except.handle}.
\begin{note}
As a consequence, an exception is considered uncaught
during any stack unwinding resulting from it being thrown.
\end{note}

\pnum
If an exception is rethrown\iref{expr.throw,propagation},
it is considered uncaught from the point of rethrow
until the rethrown exception is caught.
\indexlibraryglobal{uncaught_exceptions}%
\begin{note}
The function \tcode{std::uncaught_exceptions}\iref{uncaught.exceptions}
returns the number of uncaught exceptions in the current thread.
\end{note}

\pnum
\indextext{exception handling!terminate called@\tcode{terminate} called}%
\indextext{\idxcode{terminate}!called}%
If the exception handling mechanism
handling an uncaught exception\iref{except.uncaught}
handling an uncaught exception
directly invokes a function that exits via an
exception, the function \tcode{std::terminate} is invoked\iref{except.terminate}.
\begin{example}
Expand Down Expand Up @@ -1007,8 +1026,10 @@
The function \tcode{std::terminate}\iref{except.terminate}
is used by the exception
handling mechanism for coping with errors related to the exception handling
mechanism itself. The function
\tcode{std::current_exception()}\iref{propagation} and the class
mechanism itself.
The function \tcode{std::uncaught_exceptions}\iref{uncaught.exceptions}
reports how many exceptions are uncaught in the current thread.
The function \tcode{std::current_exception}\iref{propagation} and the class
\tcode{std::nested_exception}\iref{except.nested} can be used by a program to
capture the currently handled exception.

Expand Down Expand Up @@ -1132,21 +1153,4 @@
prematurely based on a determination that the unwind process
will eventually cause an invocation of the function
\tcode{std::terminate}.

\rSec2[except.uncaught]{The \tcode{std::uncaught_exceptions} function}%
\indexlibraryglobal{uncaught_exceptions}

\pnum
An exception is considered uncaught
after completing the initialization of the exception object\iref{except.throw}
until completing the activation of a handler for the exception\iref{except.handle}.
\begin{note}
As a consequence, an exception is considered uncaught
during any stack unwinding resulting from it being thrown.
\end{note}
If an exception is rethrown\iref{expr.throw,propagation},
it is considered uncaught from the point of rethrow
until the rethrown exception is caught.
The function \tcode{std::uncaught_exceptions}\iref{uncaught.exceptions}
returns the number of uncaught exceptions in the current thread.%
\indextext{exception handling|)}
2 changes: 1 addition & 1 deletion source/support.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3849,7 +3849,7 @@
\begin{itemdescr}
\pnum
\returns
The number of uncaught exceptions\iref{except.uncaught}.
The number of uncaught exceptions\iref{except.throw} in the current thread.

\pnum
\remarks
Expand Down
3 changes: 3 additions & 0 deletions source/xrefdelta.tex
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@
\movedxref{stoptoken.cons}{stopsource}
\movedxref{stoptoken.nonmembers}{stopsource}

% https://github.com/cplusplus/draft/pull/????
\movedxref{except.uncaught}{except.throw}

%%% Deprecated features.
%%% Example:
%
Expand Down

0 comments on commit a8257b4

Please sign in to comment.