Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Re: Exception h...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 6 Topic 9551 of 9831
Post > Topic >>

Re: Exception handling

by =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@[EMAIL PROTECTED] Apr 27, 2008 at 07:03 AM

On 27 Apr., 00:29, howa <howac...@[EMAIL PROTECTED]
> wrote:
> I have simple code which provide exception handling functions, e.g.
>
> //---------------------------------
> try {
>                 int j = 2;
>                 int k = 0;
>                 double t = j / k;

Division by zero leads to undefined behavior, see
[expr.mul]/4:

"[..] If the second operand of / or % is zero the behavior
is undefined;[..]

>         } catch (...) {
>                 cout<<"Error!";
>         }
>
> //---------------------------------
>
> VS.net told me "unhandled exception".

What is VS.net? (Just as a remark: For a reasonable
error description, you should at least specify the
rough compiler specification, e.g. Visual Studio 2005
or such).

> But isn't catch (...) will cover as the default handler?

An exception handler with ... will catch any exception
raised inside it's try block. There is no exception
raised in your code example. Note that a so-called
"floating-point exception", which might be raised
here, does not belong to the C++ exceptions. The only
****table way to handle floating-point exceptions in
upcoming C++ (which will sup****t the C99 floating-point
environment functions) is to mask these exceptions
before raising them and later use e.g. fetestexcept
to check which 'exception' has been raised.

HTH & Greetings from Bremen,

Daniel Krügler


-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 6 Posts in Topic:
Exception handling
howa <howachen@[EMAIL   2008-04-26 16:29:41 
Re: Exception handling
=?ISO-8859-1?Q?Daniel_Kr=  2008-04-27 07:03:10 
Re: Exception handling
Thomas Maeder <maeder@  2008-04-27 07:29:53 
Re: Exception handling
=?UTF-8?B?RXJpayBXaWtzdHL  2008-04-27 07:44:29 
Re: Exception handling
Otis Bricker <obricker  2008-04-27 15:45:51 
Re: Exception handling
Pavel Minaev <int19h@[  2008-04-27 15:46:59 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 2:50:35 CDT 2008.