[C++ patch] Set attributes for C++ runtime library calls

Gabriel Dos Reis gdr@integrable-solutions.net
Thu Aug 22 14:56:00 GMT 2013


On Thu, Aug 22, 2013 at 9:38 AM, Alexander Monakov <amonakov@ispras.ru> wrote:
> On Thu, 22 Aug 2013, Gabriel Dos Reis wrote:
>> >  - I would like to recall issue if we can make NEW_EXPR annotated with
>> >    MALLOC attribute.  Without it, it is basically impossible to track
>> >    any dynamically allocated objects in the middle-end
>>
>> operator new is replaceable by user program.
>
> But so is malloc?

no, malloc isn't replaceable.

>  As I understand, the reason why "malloc" attribute is not
> applicable to operator new is "placement new", which returns aliased memory.

whether 'operator new' returns aliases memory depends on the user's
implementation, but then user has to be careful so that all other
aliasing assumptions still holds.  It is not obvious it is *exactly*
like malloc, which is why we need to exercise caution.

-- Gaby



More information about the Gcc-patches mailing list