This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
destructor of static object not called
- To: gcc-bugs <gcc-bugs at gcc dot gnu dot org>
- Subject: destructor of static object not called
- From: Thomas Kunert <kunert at physik dot tu-dresden dot de>
- Date: Tue, 22 Aug 2000 10:24:16 +0200
Hi,
The code
#include <iostream>
struct A {
void f(){};
A(){ std::cout << 1 << endl; }
~A(){ for(;;); std::cout << 2 << endl;}
};
template<class T>
struct B {
B(){ a.f(); }
static A a;
};
template <class T>
A B<T>::a;
int main()
{
B<int> b;
}
gives the output
1
but should give
1
2
.
Regards,
Thomas Kunert