[Bug c++/23383] builtin array operator new is not marked with malloc attribute

rguenther at suse dot de gcc-bugzilla@gcc.gnu.org
Wed Jan 4 09:44:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23383

--- Comment #17 from rguenther at suse dot de <rguenther at suse dot de> 2012-01-04 09:43:13 UTC ---
On Wed, 4 Jan 2012, xinliangli at gmail dot com wrote:

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23383
> 
> --- Comment #16 from davidxl <xinliangli at gmail dot com> 2012-01-04 00:28:55 UTC ---
> A related topic - aliasing property of realloc -- the malloc attribute is not
> applied in the glibc header and the comment is like
> 
> /* __attribute_malloc__ is not used, because if realloc returns
>    the same pointer that was passed to it, aliasing needs to be allowed
>    between objects pointed by the old and new pointers.  *
> 
> 
> It is true that the realloc can return an address is physically aliased with
> the pointer passed to it -- but assuming no-alias by the compiler should cause
> no harm -- as all code motions/CSEs across the realloc call will not be
> possible because realloc may modify/use the memory location.
> 
> 
> Any comment on this? 

The malloc attribute assumes that the contents of the memory pointed
to by the return value is undefined, so the comment is inaccurate
but the malloc attribute can indeed be not used.

We can explicitly handle REALLOC in the points-to code to honor the
fact that it is not (we do not at the moment).



More information about the Gcc-bugs mailing list