For Programmers: Free Programming Magazines  


Home > Archive > VC Language > June 2005 > Exception handling









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Exception handling
nly

2005-06-11, 3:59 pm

Given the code:

int main()
{
try
{
int* p = 0;
*p = 0; // Cause access violation
}
catch (...)
{
puts("Caught access violation");
}
return 0;
}

If without try/catch in the code, will it pops up a Microsoft warning
messagebox of bug? With try/catch, should it not pop up such an exception
messagebox?

However, my test shows that it doesn't pop up the exception messagebox in
Debug build, but shows in Release build. Could someone have an explanantion
of this? Thanks in advance!


Doug Harrison [MVP]

2005-06-11, 3:59 pm

On Sat, 11 Jun 2005 09:35:29 -0700, nly wrote:

> Given the code:
>
> int main()
> {
> try
> {
> int* p = 0;
> *p = 0; // Cause access violation
> }
> catch (...)
> {
> puts("Caught access violation");
> }
> return 0;
> }
>
> If without try/catch in the code, will it pops up a Microsoft warning
> messagebox of bug? With try/catch, should it not pop up such an exception
> messagebox?
>
> However, my test shows that it doesn't pop up the exception messagebox in
> Debug build, but shows in Release build. Could someone have an explanantion
> of this? Thanks in advance!


See:

http://members.cox.net/doug_web/eh.htm

--
Doug Harrison
Microsoft MVP - Visual C++
nly

2005-06-11, 3:59 pm

Doug Harrison [MVP] <dsh@mvps.org> wrote in message
news:kvq38cs9aop6.jok4r2olzkny$.dlg@40tude.net...
> On Sat, 11 Jun 2005 09:35:29 -0700, nly wrote:
>
exception[color=darkred]
in[color=darkred]
explanantion[color=darkred]
>
> See:
>
> http://members.cox.net/doug_web/eh.htm
>
> --
> Doug Harrison
> Microsoft MVP - Visual C++


Thanks, I did read it.

My questions are more basic...

1. Is it correct that the general purpose of using "try/catch" is to make
sure that when an exception does occur, no Windows exception warning
messagebox will pop up?

2. The above code didn't pop up the box is due to the setting in the project
that causes a Structured Exception to be caught as a C++ exception. Is this
a correct understanding?


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com