Re: [arm-gnu] Tons of seemly extraneous code linked in c++ program
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [arm-gnu] Tons of seemly extraneous code linked in c++ program



On Sunday 29 May 2011 12:15:32 AM David Querbach wrote:
> Non-inlined destructors in g++ generate calls to operator delete() to
> handle the case where the object was allocated using operator
> new().  delete() then calls free(), which in turn brings in malloc(),
> which needs sbrk().
> 
> If you really don't want malloc() and free() dragged in, write all of your
> constructors inline 

How exactly is the ctor() and dtor() related to new and delete. Surely, 
calling new and delete calles the ctor and dtor but i dont see how the reverse 
is true or even related.

I don't see how new() and delete() can be automatically included by the 
compiler.

> and create all of your class objects in either static
> memory or on the stack.  The compiler will then deduce that delete() is not
> needed.

Why would the compiler think delete() is needed unless delete is actually 
called in code?
-- 
Cheers!
Kishore