By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,771 Members | 1,685 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,771 IT Pros & Developers. It's quick & easy.

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

P: n/a

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
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,

Lionel B
Jul 22 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.