Exception Handling

Nathan Sidwell nathan@codesourcery.com
Thu Jan 16 17:33:00 GMT 2003


Ryan Cuprak wrote:
> Hello,
>  Is it safe to throw an exception as such:
>  throw new MyException ( "method","class","message);
> 
>  and then catch it as:
>  try {
>  }
>  catch ( MyException *e ) {
>    //-- do something
>    delete e;
>  }
this is safe

>  I am just looking for some guidelines on exceptions. In doing google searches
> for info, I came across an email stating that the implementation of exceptions
> varies by compiler in that some runtime systems do a binary copy of the
> exception and then pass it to the catch etc.

You are confusing the thrown object (a pointer) with the object it points
to (the new'd MyException).

nathan

-- 
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
          The voices in my head said this was stupid too
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org




More information about the Gcc-help mailing list