Re: compile error about destructor

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



On Feb 23, 6:43 pm, George <Geo...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Thanks Abhishek,

1.

The __except handler is incorrect. There are only 3 valid values for
it. If the result of the expression for __except is anything other
than those 3 values probably it gets blocked searching for an
appropriate value (or whatever as per msdn, I am not sure what blocks
the execution) and hence the execution hangs up. You should rephrase
that as below:

Why only 3 values? What are the 3 values do you mean?

From MSDN, there are more values for exception code, check for the "Return
Value" section,

http://msdn2.microsoft.com/en-us/library/ms679356.aspx

I was not saying about the GetExceptionCode() function. It can return
variety of different codes. But the expression inside the except()
should evaluate to one of the following 3 values:

1) EXCEPTION_CONTINUE_SEARCH
2) EXCEPTION_CONTINUE_EXECUTION
3) EXCEPTION_EXECUTE_HANDLER

Depending upon the above values, the decision is made as to what needs
to be done after the __except expression evaluation. Should it go to
the handler (*_HANDLER), should it skip the handler and continue
execution from after it suppressing/ignoring the exception
(*_EXECUTION) or keep looking for the next handler (similar to
rethrowing the exception or better say, not handling it at all)
(*_SEARCH).

Read up on try-except here - http://msdn2.microsoft.com/en-us/library/s58ftw19(VS.80).aspx

2.

__try
{
   helper();
}
__except (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ?
                       EXCEPTION_EXECUTE_HANDLER :
EXCEPTION_CONTINUE_EXECUTION)
{
   cout << "access violation caught 2" << endl;
}

What is your purpose of put EXCEPTION_EXECUTE_HANDLER and
EXCEPTION_CONTINUE_EXECUTION? I do not understand the whole function of the
statemet,

__except (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ?
                       EXCEPTION_EXECUTE_HANDLER :
EXCEPTION_CONTINUE_EXECUTION)

Some more descriptions are appreciated. :-)

See above.
.



Relevant Pages

  • Re: Handling top-level exceptions
    ... that is thrown on the main thread, even if the exception is not ... the catch handler will never be called unconditionally...it will only ... and from there execution always continues at the finally ... > is run in debug mode or not. ...
    (microsoft.public.dotnet.languages.csharp)
  • Structured Exception Handling (was: Try Finally...)
    ... [MSDN: Structured Exception Handling] ... requires the execution of code outside the normal flow of control... ... whenever a guarded body of code is executed, a specified block of termination ... exception handler to handle the exception. ...
    (comp.lang.pascal.delphi.misc)
  • Re: Getting exception object
    ... Ergo, you cannot know if it is safe to continue execution or not. ... The handler would do whatever it was supposed to do, call throw; ... The performance overhead induced by throwing a true exception object instead ...
    (microsoft.public.vc.language)
  • Re: Try Finally...
    ... >finally continues at the point where the exception is handled. ... Once the Exception Record is created, the address of the handler is ... looked up from the guard frame at FS:0. ... on execution from the address of the exception itself. ...
    (comp.lang.pascal.delphi.misc)
  • Re: QC#6682 - is there a fix?
    ... >exception is not trapped properly. ... Note that OnCreate is called by your constructor, ... destroyed before your exception code is allowed to execute. ... the not be valid either in the exception handler or later. ...
    (borland.public.delphi.language.objectpascal)