code bloat from constructor and destructor generation
Stuart Hastings
stuart@apple.com
Mon Dec 9 17:53:00 GMT 2002
On Monday, Dec 9, 2002, at 11:05 US/Pacific, Clint Laschkewitsch wrote:
> I'm working on an embedded system where memory is a major constraint.
>
> In looking at code that is being generated by the gcc compiler and
> trying
> to determine how we can reduce code size, I was surprised to see 2
> copies
> of a constructor and 2 copies of a destructor in the C++ classes we
> have
> defined.
>
> For some of the C++ classes, this is not a big deal because the
> constructors and destructors are very simple and have little code.
> However, we have other classes where both the constructor and
> destructor
> have quite a bit of code to them. So getting 2 copies of each is a
> problem.
>
> Can anyone tell me why the compiler is generating two copies? What
> problem
> is the compiler trying to solve that the requires separate copies of
> the
> code? It appears that using various optimization levels (-O2, -O3,
> -Os,
> etc.) does not eliminate any copies.
>
> Also, is there anyway that this can be avoided - compiler options,
> pragmas,
> #defines, etc that would tell the compiler not to do this? If it
> helps,
> many of the C++ classes which are causing space problems will not be
> subclassed so we don't have to worry about some other class inheriting
> from
> the base class.
http://gcc.gnu.org/ml/gcc-patches/2002-08/msg00354.html
stuart hastings
Apple Computer
More information about the Gcc
mailing list