Article View: gnu.g++.bug
Article #1095Failure to call destructors of global objects
From: Markus Armbruster
Date: Fri, 06 Nov 1992 14:17
Date: Fri, 06 Nov 1992 14:17
75 lines
2596 bytes
2596 bytes
Syndrome:
The notorious hello.cc
#include <stream.h>
int main()
{
cout << "hello, world!\n";
}
compiled with gcc-2.3.1, binutils-2.0, glibc-1.05, libg++-2.2 on a
sun-4, sunos4.1 yields no output.
Diagnosis:
Destructors of global objects are never called.
Citation from __do_global_dtors() :
/* Some systems place the number of pointers
in the first word of the table.
On other systems, that word is -1.
In all cases, the table is null-terminated. */
/* If the length is not recorded, count up to the null. */
if (nptrs == -1)
for (nptrs = 0; __DTOR_LIST__[nptrs + 1] != 0; nptrs++);
Well, on my configuration (see above) the first word is always zero.
Citation from gbl-ctors.h concerning macro DO_GLOBAL_CTORS_BODY :
/* The first word may or may not contain the number of pointers in the table.
In all cases, the table is null-terminated.
We ignore the first word and scan up to the null. */
Now, that sounds reasonable.
Cure:
*** libgcc2.c~ Fri Nov 6 13:02:50 1992
--- libgcc2.c Fri Nov 6 12:59:59 1992
*************** __do_global_dtors ()
*** 1540,1553 ****
unsigned nptrs = (unsigned HOST_WIDE_INT) __DTOR_LIST__[0];
unsigned i;
! /* Some systems place the number of pointers
! in the first word of the table.
! On other systems, that word is -1.
! In all cases, the table is null-terminated. */
! /* If the length is not recorded, count up to the null. */
! if (nptrs == -1)
! for (nptrs = 0; __DTOR_LIST__[nptrs + 1] != 0; nptrs++);
/* GNU LD format. */
for (i = nptrs; i >= 1; i--)
--- 1540,1550 ----
unsigned nptrs = (unsigned HOST_WIDE_INT) __DTOR_LIST__[0];
unsigned i;
! /* The first word may or may not contain the number of pointers in the table.
! In all cases, the table is null-terminated.
! We ignore the first word and scan up to the null. */
! for (nptrs = 0; __DTOR_LIST__[nptrs + 1] != 0; nptrs++);
/* GNU LD format. */
for (i = nptrs; i >= 1; i--)
Hope that helps.
Markus
Technical Details
Message-ID:
<9211061217.AA16294@hel>Path:
arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!karlsruhe.gmd.DE!armbruShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!karlsruhe.gmd.DE!armbru From: armbru@karlsruhe.gmd.DE (Markus Armbruster) Subject: Failure to call destructors of global objects Message-ID: <9211061217.AA16294@hel> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Fri, 6 Nov 1992 14:17:54 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 76