When a constructor/destructor has a function-try-block, the code inside of the catch clause will be executed after the object has been destroyed
(if the object was partially constructed when the exception was thrown, this part will be destroyed before going in the catch block). Therefore, the
members of the object are not available, and it is undefined behavior to access them.
Since the lifetime of a static member is greater than that of the object itself, so a static member can be accessed from the catch code.
Noncompliant code example
class A {
public:
int i;
A ( ) try {
// Action that might raise an exception
} catch ( ... ) {
if ( i == 0 ) { // Noncompliant, i has been destroyed
// ...
}
}
~A ( ) try {
// Action that might raise an exception
} catch ( ... ) {
if ( i == 0 ) { // Noncompliant
// ...
}
}
};