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] Set attributes for C++ runtime library calls


On Thu, Aug 22, 2013 at 10:38 AM, Alexander Monakov <amonakov@ispras.ru> wrote:
> On Thu, 22 Aug 2013, Jan Hubicka 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?  As I understand, the reason why "malloc" attribute is not
>> > applicable to operator new is "placement new", which returns aliased memory.
>>
>> placement new is optimized to nothing, so it should not affect anything here.
>
> Which means you cannot annotate NEW_EXPR with attribute malloc when
> -fno-inline is in effect, right?  Because then placement new is no longer
> optimized out.  Testcase, compile with -O2 -fno-inline -fno-ipa-sra:
>
> #include <new>
> int foo(void *c)
> {
>   return *(new (c) int);
> }

This should be a C++ front-end bug.  The specific operator new
from <new> used in this placement-new should be folded,
even if -fno-inline.  Jason, is this something easily fixable?

After overload resolution, we know exactly which operator new
we are picking, and we know it is the one coming from the
implementation with its definition.  So we should be good to go.

-- Gaby


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