You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue description: In [expr.reinterpret.cast]/11, we have a similar issue to the one described in CWG2879: it says the operand for a cast to reference type can be a "glvalue of type T1", which combined with [basic.lval]/7 implies that a prvalue is also acceptable. No implementation accepts reinterpret_cast<double&&>(0).
Some notes in this section are also questionable:
Note 1 is not specific to reinterpret_cast. The padding bits in the source value are lost upon the lvalue-to-rvalue conversion.
The result of the expression reinterpret_cast(v) is the result of converting the expression v to type T. If T is an lvalue reference type or an rvalue reference to function type, the result is an lvalue; if T is an rvalue reference to object type, the result is an xvalue; otherwise, the result is a prvalue and the lvalue-to-rvalue, array-to-pointer, and function-to-pointer standard conversions are performed on the expression v. The temporary materialization conversion ([conv.rval]) is not performed on v. Conversions that can be performed explicitly using reinterpret_cast are listed below. No other conversion can be performed explicitly using reinterpret_cast.
Strike paragraph 3 (note 1).
Strike Note 5 from paragraph 6.
Convert the last sentence of [expr.reinterpret.cast]/11 into a note. Also, I suppose the footnote may need to be inlined into it? Having a footnote inside a note seems odd.
A glvalue of type T1, designating an object or function x, can be cast to the type “reference to T2” if an expression of type “pointer to T1” can be explicitly converted to the type “pointer to T2” using a reinterpret_cast. The result is that of *reinterpret_cast<T2 *>(p) where p is a pointer to x of type “pointer to T1”. [Note: No temporary is created, no copy is made, and no constructors ([class.ctor]) or conversion functions ([class.conv]) are called. —end note]
The text was updated successfully, but these errors were encountered:
jensmaurer
changed the title
[expr.reinterpret.cast] Do not allow reinterpret_cast from prvalue to rvalue reference
CWG2939 [expr.reinterpret.cast] Do not allow reinterpret_cast from prvalue to rvalue reference
Oct 2, 2024
Full name of submitter: Brian Bi
Reference (section label): [expr.reinterpret.cast]
Issue description: In [expr.reinterpret.cast]/11, we have a similar issue to the one described in CWG2879: it says the operand for a cast to reference type can be a "glvalue of type T1", which combined with [basic.lval]/7 implies that a prvalue is also acceptable. No implementation accepts
reinterpret_cast<double&&>(0)
.Some notes in this section are also questionable:
reinterpret_cast
. The padding bits in the source value are lost upon the lvalue-to-rvalue conversion.Suggested resolution: Edit [expr.reinterpret.cast]/1:
Strike paragraph 3 (note 1).
Strike Note 5 from paragraph 6.
Convert the last sentence of [expr.reinterpret.cast]/11 into a note. Also, I suppose the footnote may need to be inlined into it? Having a footnote inside a note seems odd.
The text was updated successfully, but these errors were encountered: