C++ & arithmetic exceptions

B

BigMan

Does the C++ standard say anything about how arithmetic exceptions
(such as integer division by 0) interfere with C++ exceptions? I see
that catch clauses DO catch arithmetic exceptions but throwing an
arithmetic exception does not abort the program if there is an uncaught
exception (even a C++ exception).
 
J

John Carson

BigMan said:
Does the C++ standard say anything about how arithmetic exceptions
(such as integer division by 0) interfere with C++ exceptions?
I see that catch clauses DO catch arithmetic exceptions but throwing an
arithmetic exception does not abort the program if there is an
uncaught exception (even a C++ exception).

The catching of exceptions that are not C++ exceptions is compiler specific.
On VC++, it is controlled by compiler settings and the rules in this respect
are going to change between VC++ 2003 and VC++2005. See here:

http://www.developer.com/net/cplus/article.php/3493706

The C++ standard, section 5 / 5 has this to say:

"If during the evaluation of an expression, the result is not mathematically
defined or not in the range of representable values for its type, the
behavior is undefined, unless such an expression is a constant expression
(5.19), in which case the program is ill-formed. [Note: most existing
implementations of C + + ignore integer overflows. Treatment of division by
zero, forming a remainder using a zero divisor, and all floating point
exceptions vary among machines, and is usually adjustable by a library
function. ]
 

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,202
Messages
2,571,057
Members
47,665
Latest member
salkete

Latest Threads

Top