... thinking more about the issue, probably the best thing to do would be wrapping instead in a COMPOUND_EXPR, which would be also consistent with cp_convert_to_pointer. Thus I'm finishing testing the below (past g++.dg). How about it?

Thanks!
Paolo.

/////////////////////
Index: cvt.c
===================================================================
--- cvt.c       (revision 259926)
+++ cvt.c       (working copy)
@@ -711,6 +711,15 @@ ocp_convert (tree type, tree expr, int convtype, i
   if (error_operand_p (e))
     return error_mark_node;
 
+  if (NULLPTR_TYPE_P (type) && null_ptr_cst_p (e))
+    {
+      if (complain & tf_warning)
+       maybe_warn_zero_as_null_pointer_constant (e, loc);
+
+      return (TREE_SIDE_EFFECTS (e)
+             ? build2 (COMPOUND_EXPR, type, e, nullptr_node) : nullptr_node);
+    }
+
   if (MAYBE_CLASS_TYPE_P (type) && (convtype & CONV_FORCE_TEMP))
     /* We need a new temporary; don't take this shortcut.  */;
   else if (same_type_ignoring_top_level_qualifiers_p (type, TREE_TYPE (e)))
@@ -832,12 +841,6 @@ ocp_convert (tree type, tree expr, int convtype, i
       /* Ignore any integer overflow caused by the conversion.  */
       return ignore_overflows (converted, e);
     }
-  if (NULLPTR_TYPE_P (type) && e && null_ptr_cst_p (e))
-    {
-      if (complain & tf_warning)
-       maybe_warn_zero_as_null_pointer_constant (e, loc);
-      return nullptr_node;
-    }
   if (POINTER_TYPE_P (type) || TYPE_PTRMEM_P (type))
     return cp_convert_to_pointer (type, e, dofold, complain);
   if (code == VECTOR_TYPE)

Reply via email to