A
Asim Hussnain
We have recently found that if a funtion throws exception and caller without
fully executing, the Stack of the function is not cleared by windows i.e. if
some object was created on Stack of the called function, its desctructor
will never be called.
Consider the code example below:
void func()
{
COURObject o(params);
int* p = 0;
* p = 1; //this code will generate exception
}
void func2()
{
try
{
func();
}
catch(...)
{
}
}
In this case, destructor of COURObject would never be called To prevent
this, WE MUST USE TRY CATCH BLOCK IN THE FUCNTION WHERE WE ARE USING
COURObject.
Is it really so? I thought that stack woould always be properly cleaned up
when exception is thrown. any comments?
fully executing, the Stack of the function is not cleared by windows i.e. if
some object was created on Stack of the called function, its desctructor
will never be called.
Consider the code example below:
void func()
{
COURObject o(params);
int* p = 0;
* p = 1; //this code will generate exception
}
void func2()
{
try
{
func();
}
catch(...)
{
}
}
In this case, destructor of COURObject would never be called To prevent
this, WE MUST USE TRY CATCH BLOCK IN THE FUCNTION WHERE WE ARE USING
COURObject.
Is it really so? I thought that stack woould always be properly cleaned up
when exception is thrown. any comments?