Skip to content

Commit aa18e13

Browse files
committed
[except.uncaught] Tidy the specification for uncaught exceptions
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.
1 parent 13ba96c commit aa18e13

File tree

3 files changed

+30
-21
lines changed

3 files changed

+30
-21
lines changed

source/exceptions.tex

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,16 @@
317317
the selected constructor is odr-used\iref{basic.def.odr} and
318318
the destructor of \tcode{T} is potentially invoked\iref{class.dtor}.
319319

320+
\pnum
321+
\indextext{exception handling!uncaught}%
322+
An exception is considered \defnx{uncaught}{uncaught exception}
323+
after completing the initialization of the exception object
324+
until completing the activation of a handler for the exception\iref{except.handle}.
325+
\begin{note}
326+
As a consequence, an exception is considered uncaught
327+
during any stack unwinding resulting from it being thrown.
328+
\end{note}
329+
320330
\pnum
321331
\indextext{exception handling!rethrow}%
322332
\indextext{rethrow|see{exception handling, rethrow}}%
@@ -327,11 +337,21 @@
327337
it is rethrown.
328338
\end{note}
329339

340+
\pnum
341+
\indexlibraryglobal{uncaught_exceptions}%
342+
If an exception is rethrown\iref{expr.throw,propagation},
343+
it is considered uncaught from the point of rethrow
344+
until the rethrown exception is caught.
345+
\begin{note}
346+
The function \tcode{std::uncaught_exceptions}\iref{uncaught.exceptions}
347+
returns the number of uncaught exceptions in the current thread.
348+
\end{note}
349+
330350
\pnum
331351
\indextext{exception handling!terminate called@\tcode{terminate} called}%
332352
\indextext{\idxcode{terminate}!called}%
333353
If the exception handling mechanism
334-
handling an uncaught exception\iref{except.uncaught}
354+
handling an uncaught exception
335355
directly invokes a function that exits via an
336356
exception, the function \tcode{std::terminate} is invoked\iref{except.terminate}.
337357
\begin{example}
@@ -1003,8 +1023,10 @@
10031023
The function \tcode{std::terminate}\iref{except.terminate}
10041024
is used by the exception
10051025
handling mechanism for coping with errors related to the exception handling
1006-
mechanism itself. The function
1007-
\tcode{std::current_exception()}\iref{propagation} and the class
1026+
mechanism itself.
1027+
The function \tcode{std::uncaught_exceptions}\iref{uncaught.exceptions}
1028+
reports how many exceptions are uncaught in the current thread.
1029+
The function \tcode{std::current_exception}\iref{propagation} and the class
10081030
\tcode{std::nested_exception}\iref{except.nested} can be used by a program to
10091031
capture the currently handled exception.
10101032

@@ -1128,21 +1150,4 @@
11281150
prematurely based on a determination that the unwind process
11291151
will eventually cause an invocation of the function
11301152
\tcode{std::terminate}.
1131-
1132-
\rSec2[except.uncaught]{The \tcode{std::uncaught_exceptions} function}%
1133-
\indexlibraryglobal{uncaught_exceptions}
1134-
1135-
\pnum
1136-
An exception is considered uncaught
1137-
after completing the initialization of the exception object\iref{except.throw}
1138-
until completing the activation of a handler for the exception\iref{except.handle}.
1139-
\begin{note}
1140-
As a consequence, an exception is considered uncaught
1141-
during any stack unwinding resulting from it being thrown.
1142-
\end{note}
1143-
If an exception is rethrown\iref{expr.throw,propagation},
1144-
it is considered uncaught from the point of rethrow
1145-
until the rethrown exception is caught.
1146-
The function \tcode{std::uncaught_exceptions}\iref{uncaught.exceptions}
1147-
returns the number of uncaught exceptions in the current thread.%
11481153
\indextext{exception handling|)}

source/support.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4013,7 +4013,7 @@
40134013
\begin{itemdescr}
40144014
\pnum
40154015
\returns
4016-
The number of uncaught exceptions\iref{except.uncaught}.
4016+
The number of uncaught exceptions\iref{except.throw} in the current thread.
40174017

40184018
\pnum
40194019
\remarks

source/xrefdelta.tex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,13 @@
9595
\movedxref{stoptoken.cons}{stopsource}
9696
\movedxref{stoptoken.nonmembers}{stopsource}
9797

98+
% https://github.com/cplusplus/draft/pull/7276
99+
\movedxref{except.uncaught}{except.throw}
100+
98101
% https://github.com/cplusplus/draft/pull/7345
99102
\movedxref{basic.stc.inherit}{basic.stc.general}
100103

104+
101105
%%% Deprecated features.
102106
%%% Example:
103107
%

0 commit comments

Comments
 (0)