- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Is there a way, using intel C++ compiler, to transform a floating point exception into a regular exception that one can catch ?
Francois
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
You can try the "fnon-call-exceptions" option which should allow trapping of SIGFPE signals. You can then catch that with your signal handler to throw a regular C++ exception....
_Kittur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Kittur,
Thanks for your help. Do you have any tutorial on how to write the signal handler? I've never done such a thing and I can't find anything on the internet. I just found this article that deals with fortran: https://software.intel.com/en-us/node/510891 .
By the way, can you handle those signals on Windows too?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
> Thanks for your help. Do you have any tutorial on how to write the signal handler? I've never done such a thing and I can't find anything on....
Nope, other than the samples given on the Fortran link you show there's no other tutorial that I am aware of. On Windows*, the OS provides exception handling using SEH (Structured exception handling) but the compiler doesn't include extensions for SEH support except it uses the built-in exception handling mechanism. On the other hand, on Linux the libstdc++ provides the exception handling capability. As such note that there's no fnon-call-exceptions option for Windows in the compiler. That said, basically you can write a signal handler to catch a signal and throw an exception. An exception can be thrown inside the try block() and can be handled within a catch block accordingly. BTW, googling on SIGFPE exception handling example shows quite a few results that pretty much show the generic template code for a generic signal handler function that should help (such as: http://www.cplusplus.com/doc/tutorial/exceptions/", "http://www.yolinux.com/TUTORIALS/C++Signals.html" and so on... Also, the fortran examples link you show also uses similar template (try/catch blocks)
.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page