Skip to content

Commit afaa669

Browse files
burblebeetkoeppe
authored andcommitted
CWG2939 Do not allow reinterpret_cast from prvalue to rvalue reference
1 parent 8384ae9 commit afaa669

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

source/expressions.tex

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@
266266
\end{note}
267267

268268
\pnum
269-
Unless otherwise specified\iref{expr.const.cast},
269+
Unless otherwise specified\iref{expr.reinterpret.cast, expr.const.cast},
270270
whenever a prvalue appears as an operand of an operator that
271271
expects a glvalue for that operand, the
272272
temporary materialization conversion\iref{conv.rval} is
@@ -4432,9 +4432,6 @@
44324432
\tcode{T2}'' (where \tcode{T1} and \tcode{T2} are function types) and
44334433
back to its original type yields the original pointer value, the result
44344434
of such a pointer conversion is unspecified.
4435-
\begin{note}
4436-
See also~\ref{conv.ptr} for more details of pointer conversions.
4437-
\end{note}
44384435

44394436
\pnum
44404437
An object pointer
@@ -4509,22 +4506,25 @@
45094506
\indextext{cast!reinterpret!reference}%
45104507
\indextext{cast!reference}%
45114508
\indextext{type pun}%
4512-
A glvalue of type \tcode{T1},
4509+
If \tcode{v} is a glvalue of type \tcode{T1},
45134510
designating an object or function \placeholder{x},
4514-
can be cast to the type ``reference to \tcode{T2}''
4511+
it can be cast to the type ``reference to \tcode{T2}''
45154512
if an expression of type ``pointer to \tcode{T1}''
45164513
can be explicitly converted to the type ``pointer to \tcode{T2}''
45174514
using a \keyword{reinterpret_cast}.
45184515
The result is that of \tcode{*reinterpret_cast<T2 *>(p)}
45194516
where \tcode{p} is a pointer to \placeholder{x}
45204517
of type ``pointer to \tcode{T1}''.
4521-
No temporary is created, no copy is made, and
4518+
\begin{note}
4519+
No temporary is materialized\iref{conv.rval} or created,
4520+
no copy is made, and
45224521
no constructors\iref{class.ctor} or conversion
45234522
functions\iref{class.conv} are called.
45244523
\begin{footnote}
45254524
This is sometimes referred to as a type pun
45264525
when the result refers to the same object as the source glvalue.
45274526
\end{footnote}
4527+
\end{note}
45284528

45294529
\rSec3[expr.const.cast]{Const cast}
45304530

0 commit comments

Comments
 (0)