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

C++ & arithmetic exceptions

P: n/a
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).

Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"BigMan" <Bi****@abv.bg> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com
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. ]
--
John Carson

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.