According to MSDN:
The __leave statement is more efficient because it does not cause stack unwinding.
To my understanding, that is to say: "Such a common code snippet is dangerous!"
struct A
{
int* p;
A() : p(new int) {}
~A() { delete p; }
};
void f()
{
__try
{
A a;
... // Doing somthing
if (the thing has gone bad) __leave;
... // Continue
}
__finally
{}
}
Is it a best practice to totally avoid __leave in C++ projects?
http://msdn.microsoft.com/en-us/library/yb3kz605.aspx
says:
For C++ programs, C++ exception handling should be used instead of structured exception handling. For more information, see Exception Handling in the C++ Language Reference.
Edit: Also, it's usually good to refrain from compiler specific features.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With