I wrote this code as follows:
#include <iostream>
using namespace std;
class T
{
public:
T()
{
cout << "bb\n";
this -> ~T();
cout << "zz" << endl;
}
~T()
{
cout << "hello\n";
};
};
int main()
{
T a;
return 0;
}
T a;
T a()
bb
hello
zz
hello
This is undefined behaviour: you're calling the destructor on an object which has not yet been fully constructed.