Someone was noticing that whether the result of reinterpret_cast<int>
was an lvalue or rvalue depended on constant folding. It should always
be an rvalue.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit ff6494228a9bc40c7b78109163054840c1e44855
Author: Jason Merrill <ja...@redhat.com>
Date: Sat Nov 8 15:35:38 2014 -0600
DR 799
* typeck.c (build_reinterpret_cast_1): reinterpret_cast to the
same scalar type is an rvalue.
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 99f4b88..d0f5ccd 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -6898,7 +6898,7 @@ build_reinterpret_cast_1 (tree type, tree expr, bool c_cast_p,
|| TYPE_PTR_OR_PTRMEM_P (type))
&& same_type_p (type, intype))
/* DR 799 */
- return fold_if_not_in_template (build_nop (type, expr));
+ return rvalue (expr);
else if ((TYPE_PTRFN_P (type) && TYPE_PTRFN_P (intype))
|| (TYPE_PTRMEMFUNC_P (type) && TYPE_PTRMEMFUNC_P (intype)))
return fold_if_not_in_template (build_nop (type, expr));
diff --git a/gcc/testsuite/g++.dg/conversion/reinterpret1.C b/gcc/testsuite/g++.dg/conversion/reinterpret1.C
index aa55f6f..d456782 100644
--- a/gcc/testsuite/g++.dg/conversion/reinterpret1.C
+++ b/gcc/testsuite/g++.dg/conversion/reinterpret1.C
@@ -3,4 +3,4 @@
struct Y { Y(int &); };
int v;
-Y y1(reinterpret_cast<int>(v));
+Y y1(reinterpret_cast<int>(v)); // { dg-error "" }