This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
(egcs-1.1) bug in linkonce for auto-generated virt destructors
- To: egcs-bugs at cygnus dot com
- Subject: (egcs-1.1) bug in linkonce for auto-generated virt destructors
- From: Mumit Khan <khan at xraylith dot wisc dot edu>
- Date: Fri, 02 Oct 1998 01:28:19 -0500
The following code shows a bug in egcs-1.1 branch for all x86-win32
targets when derived template classes don't define virtual destructors.
If the destructor is not defined for the derived class, then when
explicitly instantiating the template, the compiler generated
destructor does not get put in required/expected linkonce sections
causing multiple definition errors.
This seems to be fixed in the development tree however, but I'd like
to figure out the change that did fix it (and hopefully get that added
to the release branch).
With auto-generated destructor for explicitly instantiated Derived<double>
(wrong):
$ i386-mingw32-nm tinst-linkonce.o | grep \$_t7Derived1Zd
00000000 T __$_t7Derived1Zd
With defined destructor for explicitly instantiated Derived<double>, get
the expected (and correct) linkage:
$ i386-mingw32-nm tinst-linkonce.o | grep \$_t7Derived1Zd
00000000 t .text$_$_t7Derived1Zd
00000000 T __$_t7Derived1Zd
============ test case
template <class T>
struct Base {
virtual ~Base () { }
};
template <class T>
struct Derived : Base<T> {
#ifdef DEFINE_DESTRUCTOR_TO_AVOID_BUG
virtual ~Derived () { }
#endif
int bar (Derived* d) { delete d; }
};
template class Derived<double>;
============
Regards,
Mumit