diff mbox

C++ PATCH for DR 1338 (operator new aliasing)

Message ID 534831D5.7000207@redhat.com
State New
Headers show

Commit Message

Jason Merrill April 11, 2014, 6:17 p.m. UTC
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.

Comments

Jan Hubicka April 14, 2014, 6:46 a.m. UTC | #1
> 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.

Amazing, thanks a lot!

Honza
Richard Biener April 14, 2014, 9:58 a.m. UTC | #2
On Mon, Apr 14, 2014 at 8:46 AM, Jan Hubicka <hubicka@ucw.cz> wrote:
>> 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.
>
> Amazing, thanks a lot!

That leaves out the possibility of implementations initializing the
new memory (basically it's an issue when objects already reachable
to the caller are now reachable indirectly through the newly allocated
and initialized memory).

Richard.

> Honza
diff mbox

Patch

commit decb849d1c9670c5e5cd07e1bea776244ae9a9d2
Author: Jason Merrill <jason@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);