J
JKop
An excerpt from the Standard:
4 Calling the function
void exit(int);
declared in <cstdlib> (18.3) terminates the program without leaving the
current block and hence without
destroying any objects with automatic storage duration (12.4). If exit is
called to end a program during
the destruction of an object with static storage duration, the program has
undefined behavior.
Now take the following code:
#include <cstdlib>
#include <iostream>
class Blah
{
public:
~Blah()
{
std::cout << "\nBlah's Destructor!\n";
}
};
int main()
{
Blah blah;
{ exit(0); }
}
I myself would've thought that blah's destructor *would* have been called...
after all, its scope isn't that of "the current block".
Thoughts?
-JKop
4 Calling the function
void exit(int);
declared in <cstdlib> (18.3) terminates the program without leaving the
current block and hence without
destroying any objects with automatic storage duration (12.4). If exit is
called to end a program during
the destruction of an object with static storage duration, the program has
undefined behavior.
Now take the following code:
#include <cstdlib>
#include <iostream>
class Blah
{
public:
~Blah()
{
std::cout << "\nBlah's Destructor!\n";
}
};
int main()
{
Blah blah;
{ exit(0); }
}
I myself would've thought that blah's destructor *would* have been called...
after all, its scope isn't that of "the current block".
Thoughts?
-JKop