Skip to content

Commit 3d5d613

Browse files
burblebeetkoeppe
authored andcommitted
CWG2882 Unclear treatment of conversion to void
1 parent 0193ee8 commit 3d5d613

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

source/expressions.tex

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4119,7 +4119,22 @@
41194119
a program that necessitates such a cast is ill-formed.
41204120

41214121
\pnum
4122-
An expression $E$ can be explicitly converted to a type \tcode{T}
4122+
Any expression can be explicitly converted to type \cv{}~\keyword{void},
4123+
in which case the operand is a discarded-value expression\iref{expr.prop}.
4124+
\begin{note}
4125+
Such a \keyword{static_cast} has no result
4126+
as it is a prvalue of type \keyword{void}; see~\ref{basic.lval}.
4127+
\end{note}
4128+
\begin{note}
4129+
However, if the value is in a temporary
4130+
object\iref{class.temporary}, the destructor for that
4131+
object is
4132+
not executed until the usual time, and the value of the object is
4133+
preserved for the purpose of executing the destructor.
4134+
\end{note}
4135+
4136+
\pnum
4137+
Otherwise, an expression $E$ can be explicitly converted to a type \tcode{T}
41234138
if there is an implicit conversion sequence\iref{over.best.ics}
41244139
from $E$ to \tcode{T},
41254140
if overload resolution for a direct-initialization\iref{dcl.init}
@@ -4147,28 +4162,8 @@
41474162
\end{note}
41484163

41494164
\pnum
4150-
Otherwise, the \keyword{static_cast} shall perform one of the conversions
4151-
listed below. No other conversion shall be performed explicitly using a
4152-
\keyword{static_cast}.
4153-
4154-
\pnum
4155-
Any expression can be explicitly converted to type \cv{}~\keyword{void},
4156-
in which case the operand is a discarded-value expression\iref{expr.prop}.
4157-
\begin{note}
4158-
Such a \keyword{static_cast} has no result
4159-
as it is a prvalue of type \keyword{void}; see~\ref{basic.lval}.
4160-
\end{note}
4161-
\begin{note}
4162-
However, if the value is in a temporary
4163-
object\iref{class.temporary}, the destructor for that
4164-
object is
4165-
not executed until the usual time, and the value of the object is
4166-
preserved for the purpose of executing the destructor.
4167-
\end{note}
4168-
4169-
4170-
\pnum
4171-
The inverse of any standard conversion sequence\iref{conv} not containing an
4165+
Otherwise,
4166+
the inverse of a standard conversion sequence\iref{conv} not containing an
41724167
lvalue-to-rvalue\iref{conv.lval},
41734168
array-to-pointer\iref{conv.array},
41744169
function-to-pointer\iref{conv.func},
@@ -4312,6 +4307,9 @@
43124307
\end{codeblock}
43134308
\end{example}
43144309

4310+
\pnum
4311+
No other conversion can be performed using \keyword{static_cast}.
4312+
43154313
\rSec3[expr.reinterpret.cast]{Reinterpret cast}
43164314

43174315
\pnum

0 commit comments

Comments
 (0)