This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
code bloat from constructor and destructor generation
- From: "Clint Laschkewitsch" <clintl at us dot ibm dot com>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 9 Dec 2002 13:05:54 -0600
- Subject: code bloat from constructor and destructor generation
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.
Thanks.
Clint Laschkewitsch