Skip to content

[expr.throw] Make wording for throw-expressions more consistent with [expr] CWG2699 #3921

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 11 additions & 19 deletions source/expressions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6584,19 +6584,21 @@
A \grammarterm{throw-expression} is of type \tcode{void}.

\pnum
Evaluating a \grammarterm{throw-expression} with an operand throws an
exception\iref{except.throw}; the type of the exception object is determined by removing
any top-level \grammarterm{cv-qualifier}{s} from the static type of the
operand and adjusting the type
from ``array of \tcode{T}'' or function type \tcode{T}
to ``pointer to \tcode{T}''.
A \grammarterm{throw-expression} with an operand throws an exception\iref{except.throw}.
The array-to-pointer\iref{conv.array} and function-to-pointer\iref{conv.func}
standard conversions are performed on the operand.
The type of the exception object\iref{except.throw} is determined by
removing any top-level cv-qualifiers from the type of the (possibly-converted) operand.
Comment on lines +6588 to +6591
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is technically a normative change: previously throwing a const char[3] would throw a char* rather than const char*. But the old wording is sufficiently obviously wrong that that seems OK.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see that's #3959. I even managed to pick exactly the same example!


\pnum
\indextext{exception handling!rethrow}%
A
\grammarterm{throw-expression}
\indextext{exception handling!terminate called@\tcode{terminate} called}%
\indextext{\idxcode{terminate}!called}%
A \grammarterm{throw-expression}
with no operand rethrows the currently handled exception\iref{except.handle}.
The exception is reactivated with the existing exception object;
If no exception is currently being handled,
the function \tcode{std::terminate} is called\iref{except.terminate}.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
the function \tcode{std::terminate} is called\iref{except.terminate}.
the function \tcode{std::terminate} is invoked\iref{except.terminate}.

Copy link
Member

@zygoloid zygoloid Oct 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally-speaking, we consider "call" to be syntactic (f(a,b) is a function call) and "invoke" to be semantic (a + b for an overloaded operator+ invokes a function but doesn't involve a function call). This terminology isn't used consistently everywhere, but it seems like a good idea to use the more-precise terminology in wording we're touching anyway.

Otherwise, the exception is reactivated with the existing exception object;
no new exception object is created.
The exception is no longer considered to be caught.
\begin{example}
Expand All @@ -6612,16 +6614,6 @@
\end{codeblock}
\end{example}

\pnum
\indextext{exception handling!rethrow}%
\indextext{exception handling!terminate called@\tcode{terminate} called}%
\indextext{\idxcode{terminate}!called}%
If no exception is presently being handled,
evaluating a
\grammarterm{throw-expression}
with no operand calls
\tcode{std::\brk{}terminate()}\iref{except.terminate}.

\rSec2[expr.ass]{Assignment and compound assignment operators}%
\indextext{expression!assignment and compound assignment}

Expand Down