This is the mail archive of the gcc-help@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]

Double the constructors, double the fun


Hi. gcc 3.0 seems to be generating two constructors, which are
exactly the same for every constructor I write.
Take the following example:
foo.cpp:
class foo {
public :
  foo ();
};

foo::foo() { }

main() { }

> gcc foo.cpp -o foo
> objdump -d foo

08048760 <_ZN3fooC2Ev>:
 8048760:       55                      push   %ebp
 8048761:       89 e5                   mov    %esp,%ebp
 8048763:       83 ec 04                sub    $0x4,%esp
 8048766:       c9                      leave
 8048767:       c3                      ret

08048768 <_ZN3fooC1Ev>:
 8048768:       55                      push   %ebp
 8048769:       89 e5                   mov    %esp,%ebp
 804876b:       83 ec 04                sub    $0x4,%esp
 804876e:       c9                      leave
 804876f:       c3                      ret

Why are there 2 constructors generated? I am working in a memory
limited environment and can't afford this kind of waste (if waste it be).
I should also note that gcc 2.95.3 doesn't do this. I searched all the
mailing lists and couln't find anything. Thanks for your help!
--
Tim Housel


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