===================================================================
@@ -1,4 +1,5 @@
// PR c++/15076
+// { dg-options -std=c++98 }
struct Y { Y(int &); };
===================================================================
@@ -0,0 +1,5 @@
+// PR c++/51379
+// { dg-options -std=c++0x }
+
+unsigned long t1 = 1;
+unsigned long t2 = reinterpret_cast<unsigned long>(t1);
===================================================================
@@ -6203,6 +6203,11 @@ build_reinterpret_cast_1 (tree type, tree expr, bo
else if (TYPE_PTR_P (type) && INTEGRAL_OR_ENUMERATION_TYPE_P (intype))
/* OK */
;
+ else if ((cxx_dialect != cxx98)
+ && (INTEGRAL_OR_ENUMERATION_TYPE_P (type)
+ || TYPE_PTR_P (type) || TYPE_PTR_TO_MEMBER_P (type))
+ && same_type_p (type, intype))
+ return fold_if_not_in_template (build_nop (type, 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));