On 11/30/2012 04:05 PM, Paolo Carlini wrote:
@@ -219,10 +219,15 @@ cp_convert_to_pointer (tree type, tree expr, tsubs
-       expr = build_int_cst (type, 0);
+       expr = (TREE_SIDE_EFFECTS (expr)
+               ? build_nop (type, expr)
+               : build_int_cst (type, 0));

This seems to rely on a nop being sufficient to convert from any null pointer constant to the appropriate pointer type, which I don't think is safe if the integer is smaller than a pointer.

I'm also not sure if we want to rely on nullptr_t expressions actually having the value 0.

-      pfn = build_c_cast (input_location, type, nullptr_node);
+      pfn = (TREE_SIDE_EFFECTS (pfn)
+            ? build_nop (type, pfn)
+            : build_c_cast (input_location, type, nullptr_node));

Here we should be able to just convert pfn to the appropriate function pointer type so that we don't need to duplicate the logic.

Jason

Reply via email to