From 44d22b8ca61581015a0bb2263623211cfb97fa63 Mon Sep 17 00:00:00 2001 From: Alisdair Meredith Date: Tue, 1 Oct 2024 09:20:10 -0400 Subject: [PATCH 1/2] [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. --- source/exceptions.tex | 39 +++++++++++++++++++++------------------ source/support.tex | 2 +- source/xrefdelta.tex | 3 +++ 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/source/exceptions.tex b/source/exceptions.tex index 7d050c33c9..efad7b29d6 100644 --- a/source/exceptions.tex +++ b/source/exceptions.tex @@ -317,6 +317,26 @@ the selected constructor is odr-used\iref{basic.def.odr} and the destructor of \tcode{T} is potentially invoked\iref{class.dtor}. +\pnum +\indextext{exception handling!uncaught}% +An exception is considered \defnx{uncaught}{uncaught exception} +after completing the initialization of the exception object +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 +\indexlibraryglobal{uncaught_exceptions}% +If an exception is rethrown\iref{expr.throw,propagation}, +it is considered uncaught from the point of rethrow +until the rethrown exception is caught. +\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!rethrow}% \indextext{rethrow|see{exception handling, rethrow}}% @@ -331,7 +351,7 @@ \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} @@ -1127,21 +1147,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|)} diff --git a/source/support.tex b/source/support.tex index 28c15ac913..c8e0d789ae 100644 --- a/source/support.tex +++ b/source/support.tex @@ -4013,7 +4013,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 diff --git a/source/xrefdelta.tex b/source/xrefdelta.tex index a2d81a3c39..c970ddbce9 100644 --- a/source/xrefdelta.tex +++ b/source/xrefdelta.tex @@ -95,6 +95,9 @@ \movedxref{stoptoken.cons}{stopsource} \movedxref{stoptoken.nonmembers}{stopsource} +% https://github.com/cplusplus/draft/pull/7276 +\movedxref{except.uncaught}{except.throw} + % https://github.com/cplusplus/draft/pull/7345 \movedxref{basic.stc.inherit}{basic.stc.general} From 9b8c25a3d509d8e1a45328d4d3540e547778c4a5 Mon Sep 17 00:00:00 2001 From: Alisdair Meredith Date: Wed, 20 Nov 2024 02:07:51 +0100 Subject: [PATCH 2/2] [except.special.general] Complete the set of clause 17 references --- source/exceptions.tex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/exceptions.tex b/source/exceptions.tex index efad7b29d6..e15fc1cdba 100644 --- a/source/exceptions.tex +++ b/source/exceptions.tex @@ -1023,8 +1023,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.