forum.alglib.net
http://forum.alglib.net/

catch(...)
http://forum.alglib.net/viewtopic.php?f=2&t=610
Page 1 of 1

Author:  romsky [ Wed Aug 22, 2012 8:54 am ]
Post subject:  catch(...)

Hi,

The code of the pearsoncorr2 contains following try/catch block.

try
{
...
}
catch(alglib_impl::ae_error_type)
{
throw ap_error(_alglib_env_state.error_msg);
}
catch(...)
{
throw;
}

My program crashes in the last catch(...) clause .
What exceptions are to be catched by that catch(...) clause ?

Isn't be better to remove that clause at all?

Author:  Sergey.Bochkanov [ Thu Aug 23, 2012 6:39 am ]
Post subject:  Re: catch(...)

What do you mean by "crashes in the last catch(...) clause"? Does it crash because of unhandled exception other than alglib_impl::ae_error_type? If so, can you post code which makes ALGLIB to crash? The only exception ALGLIB should throw under normal circumstances is alglib_impl::ae_error_type

Author:  romsky [ Thu Aug 23, 2012 9:15 am ]
Post subject:  Re: catch(...)

From one side that was my wrong interpritation of dump analysis showing me the "throw;" as the crash line, rather then as the *next* executable line code.
Sorry for misleading on that!

Indead my programm crashed while it did not handle alglib_impl::ap_error exception.

Anyway, I fill very unconfortable when I see the code like that :

catch(...)
{
throw;
}

and that:

double result = ...;
return *(reinterpret_cast<double*>(&result));

Author:  Sergey.Bochkanov [ Thu Aug 23, 2012 10:45 am ]
Post subject:  Re: catch(...)

I agree with your opinion on catch(...), it will be removed in the next release. As for reinterpret_cast, it is necessary in some cases, and the whole code is automatically generated, so it was very easy just to include it anywhere, independently of whether it is actually needed or not. I will think on this issue, maybe it will be removed in "easy" cases.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/