In VC++7 if I do the following:
void myTerminate()
{
cout << "In myTerminate()";
abort();
}
int main( int, char** )
{
set_terminate( &myTerminate );
set_terminate( 0 );
terminate();
return 0;
}
the program behaves exactly as if abort() was called directly which is exactly what default terminate() handler does.
If I omit the set_terminate( 0 ); statement my terminate handler is being called. So calling set_terminate( 0 ) seems to have the effect of resetting the terminate() handler to default.
Is this behavior specific to VC++7 only? Won't the program run into undefined behavior if I call set_terminate( 0 ) on some other implementation?