This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ Patch] PR 54170


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]