At the last C++ meeting I got the committee to accept wording that ought to allow us to set DECL_IS_MALLOC on the built-in operator new:

Furthermore, for the library allocation functions in 18.6.1.1 [new.delete.single] and 18.6.1.2 [new.delete.array], p0 shall point to a block of storage disjoint from the storage for any other object accessible to the caller.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit decb849d1c9670c5e5cd07e1bea776244ae9a9d2
Author: Jason Merrill <ja...@redhat.com>
Date:   Tue Feb 18 09:15:02 2014 -0500

    	DR 1338
    	* decl.c (cxx_init_decl_processing): Set DECL_IS_MALLOC on
    	built-in operator new.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 3400594..069b374 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -3847,8 +3847,12 @@ cxx_init_decl_processing (void)
     newtype = build_exception_variant (newtype, new_eh_spec);
     deltype = cp_build_type_attribute_variant (void_ftype_ptr, extvisattr);
     deltype = build_exception_variant (deltype, empty_except_spec);
-    DECL_IS_OPERATOR_NEW (push_cp_library_fn (NEW_EXPR, newtype, 0)) = 1;
-    DECL_IS_OPERATOR_NEW (push_cp_library_fn (VEC_NEW_EXPR, newtype, 0)) = 1;
+    tree opnew = push_cp_library_fn (NEW_EXPR, newtype, 0);
+    DECL_IS_MALLOC (opnew) = 1;
+    DECL_IS_OPERATOR_NEW (opnew) = 1;
+    opnew = push_cp_library_fn (VEC_NEW_EXPR, newtype, 0);
+    DECL_IS_MALLOC (opnew) = 1;
+    DECL_IS_OPERATOR_NEW (opnew) = 1;
     global_delete_fndecl = push_cp_library_fn (DELETE_EXPR, deltype, ECF_NOTHROW);
     push_cp_library_fn (VEC_DELETE_EXPR, deltype, ECF_NOTHROW);
 

Reply via email to