Skip to content

Commit 37c8ec7

Browse files
committed
CWG2882 Unclear treatment of conversion to void
1 parent 630fb28 commit 37c8ec7

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
@@ -4117,7 +4117,22 @@
41174117
a program that necessitates such a cast is ill-formed.
41184118

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

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

4308+
\pnum
4309+
No other conversion can be performed using \keyword{static_cast}.
4310+
43134311
\rSec3[expr.reinterpret.cast]{Reinterpret cast}
43144312

43154313
\pnum

0 commit comments

Comments
 (0)