[Bug c++/13660] New: Multiple generation of constructors and destructors

Rainer dot Bensch at rsd dot rohde-schwarz dot com gcc-bugzilla@gcc.gnu.org
Mon Jan 12 16:57:00 GMT 2004


(non-inline) Constructors and destructors are placed in the .o file multiple 
times, constructors usually twice, destructors three times. For the example 
below from the standard library the mangled names of the destructor copies are

_ZNSt13bad_exceptionD2Ev
_ZNSt13bad_exceptionD1Ev
_ZNSt13bad_exceptionD0Ev

with D2 and D1 having exactly the same code, D0's code looks like not being 
optimized. All of this destructors call the same destructor of the base class,

_ZNSt9exceptionD2Ev

which also has unused siblings ...D1... and ...D0...

This code generation concept is also used when compiling user classes
which leads to a considerable blow up of the application by dead code.

(using -c -O2 -g -fno-rtti -fno-gnu-keywords -msoft-float -fmerge-all-constants
       -fno-inline-functions -fno-implement-inlines -fno-weak 
       -Wall -Winline -Woverloaded-virtual -Wsynth -Wreturn-type
       -Wmultichar -Wfloat-equal -Wmissing-declarations 
       -Wno-ctor-dtor-privacy -Wno-missing-declarations -Wno-parentheses
       -Wa,-m405)


Link map:                               
---------

 .text  0x00053098  0xf4 C:\Programme\OSE\powerpc\lib\gcc\libsupc++.a
(eh_exception.o)
        0x00053098           std::exception::~exception()
        0x0005317c           std::exception::what() const
        0x000530e4           std::bad_exception::~bad_exception()
        0x00053110           std::bad_exception::~bad_exception()
        0x0005313c           std::bad_exception::~bad_exception()
        0x000530a8           std::exception::~exception()
        0x000530b8           std::exception::~exception()


The cross reference looks like:
-------------------------------
std::bad_exception::~bad_exception()  
C:\Programme\OSE\powerpc\lib\gcc\libsupc++.a(eh_exception.o)
std::bad_exception::~bad_exception()  
C:\Programme\OSE\powerpc\lib\gcc\libsupc++.a(eh_exception.o)
                                      
C:\Programme\OSE\powerpc\lib\gcc\libstdc++.a(functexcept.o)
                                      
C:\Programme\OSE\powerpc\lib\gcc\libsupc++.a(eh_personality.o)
std::bad_exception::~bad_exception()  
C:\Programme\OSE\powerpc\lib\gcc\libsupc++.a(eh_exception.o)


(There may be a linker option to not include unused code but I haven't found
 one in the documentation.)

-- 
           Summary: Multiple generation of constructors and destructors
           Product: gcc
           Version: 3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Rainer dot Bensch at rsd dot rohde-schwarz dot com
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: WIN
GCC target triplet: PPC


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13660



More information about the Gcc-bugs mailing list