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

Use of atexit for destructors on Solaris 7.



Hi,

I've just encountered a problem with the implementation
of destructors on Solaris 7.    It seems the use the
'atexit' function, this function registers at most 34
functions under solaris 7.

Compiler version:

% g++ -v
Reading specs from /opt/GNUdevelop/gcc-2.95.2/lib/gcc-lib/sparc-sun-solaris2.7/
2.95.2/specs
gcc version 2.95.2 19991024 (release)


I've written a short program to show the problem. The program outputs 
the following an 'x' for each constructor and a 'y' for each destructor.
The programs outputs the followin:

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy


Showing not all the destructors where called.  I've had a hunt
around the faq's and egcs-bugs archive and haven't found
any work arounds mentioned.


//-------------------------------------------------------

#include <iostream.h>

class TestC {
public:

  TestC() 
    { cerr << "x"; }
  //: 

  ~TestC() 
    { cerr << "y"; }
  //: 

};

TestC &test0() { static TestC a; return a; }
TestC &test1() { static TestC a; return a; }
TestC &test2() { static TestC a; return a; }
TestC &test3() { static TestC a; return a; }
TestC &test4() { static TestC a; return a; }
TestC &test5() { static TestC a; return a; }
TestC &test6() { static TestC a; return a; }
TestC &test7() { static TestC a; return a; }
TestC &test8() { static TestC a; return a; }
TestC &test9() { static TestC a; return a; }
TestC &test10() { static TestC a; return a; }
TestC &test11() { static TestC a; return a; }
TestC &test12() { static TestC a; return a; }
TestC &test13() { static TestC a; return a; }
TestC &test14() { static TestC a; return a; }
TestC &test15() { static TestC a; return a; }
TestC &test16() { static TestC a; return a; }
TestC &test17() { static TestC a; return a; }
TestC &test18() { static TestC a; return a; }
TestC &test19() { static TestC a; return a; }
TestC &test20() { static TestC a; return a; }
TestC &test21() { static TestC a; return a; }
TestC &test22() { static TestC a; return a; }
TestC &test23() { static TestC a; return a; }
TestC &test24() { static TestC a; return a; }
TestC &test25() { static TestC a; return a; }
TestC &test26() { static TestC a; return a; }
TestC &test27() { static TestC a; return a; }
TestC &test28() { static TestC a; return a; }
TestC &test29() { static TestC a; return a; }
TestC &test30() { static TestC a; return a; }
TestC &test31() { static TestC a; return a; }
TestC &test32() { static TestC a; return a; }
TestC &test33() { static TestC a; return a; }
TestC &test34() { static TestC a; return a; }
TestC &test35() { static TestC a; return a; }
TestC &test36() { static TestC a; return a; }
TestC &test37() { static TestC a; return a; }
TestC &test38() { static TestC a; return a; }
TestC &test39() { static TestC a; return a; }

int main() {
  
  test0(); test1(); test2(); test3(); test4(); 
  test5(); test6(); test7(); test8(); test9(); 
  test10(); test11(); test12(); test13(); test14();
  test15(); test16(); test17(); test18(); test19();
  test20(); test21(); test22(); test23(); test24();
  test25(); test26(); test27(); test28(); test29();
  test30(); test31(); test32(); test33(); test34();
  test35(); test36(); test37(); test38(); test39();
  
  cerr << "\n";
}


Cheers,

Charles.



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