public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/13660] New: Multiple generation of constructors and destructors
@ 2004-01-12 16:57 Rainer dot Bensch at rsd dot rohde-schwarz dot com
  2004-01-12 17:12 ` [Bug c++/13660] " bangerth at dealii dot org
  0 siblings, 1 reply; 2+ messages in thread
From: Rainer dot Bensch at rsd dot rohde-schwarz dot com @ 2004-01-12 16:57 UTC (permalink / raw)
  To: gcc-bugs

(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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/13660] Multiple generation of constructors and destructors
  2004-01-12 16:57 [Bug c++/13660] New: Multiple generation of constructors and destructors Rainer dot Bensch at rsd dot rohde-schwarz dot com
@ 2004-01-12 17:12 ` bangerth at dealii dot org
  0 siblings, 0 replies; 2+ messages in thread
From: bangerth at dealii dot org @ 2004-01-12 17:12 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-01-12 17:12 -------
This is to be expected. The compiler has to generate multiple 
copies of c/dtors for cases with multiple and/or virtual inheritance. 
 
In some (probably most) cases, their code is actually the same, and 
could be merged. This is an optimization that gcc presently does not 
have. We have an open PR for this, though, see PR 3187. 
 
W. 

*** This bug has been marked as a duplicate of 3187 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-01-12 17:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-12 16:57 [Bug c++/13660] New: Multiple generation of constructors and destructors Rainer dot Bensch at rsd dot rohde-schwarz dot com
2004-01-12 17:12 ` [Bug c++/13660] " bangerth at dealii dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).