IEEE 754 floating-point "exception" -> C++ exception

L

Lionel B

Greetings,

Using gcc (GCC) 3.3.3 (cygwin special) on Win2K

Does anyone know if there is a convenient mechanism to cause a C++
exception to be thrown whenever a IEEE 754 floating-point "exception"
is raised?

Currently I a check the FPU status word wherever I wish to test for FP
errors and throw a C++ exception accordingly. This is fine; but
(particularly for testing/debugging) it would be useful to be able to
trap FP errors _wherever_ they might ocurr.

The GNU libc documentation
http://www.gnu.org/software/libc/manual/html_node/FP-Exceptions.html
states that it is possible to enable traps for FP exceptions such that
an FP exception generates a SIGFPE signal. One solution then might be
to define a handler for SIGFPE that throws an exception - however, I
suspect signal handlers and C++ exceptions may not play together
nicely... In any case neither the GNU libc documentation (nor gcc
docs) suggest how to enable FP trapping.

Any hints gratefully accepted,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,176
Messages
2,570,947
Members
47,498
Latest member
log5Sshell/alfa5

Latest Threads

Top