Boost logo

Boost :

From: Bill Klein (bill_at_[hidden])
Date: 2000-05-28 08:25:32


> > Now if you try to run it in release
> > mode, you'll see that it *doesn't* get caught!

>I have tried both options with my test program, and they exhibit
>identical behaviors. I think what the Microsoft documentation says
>is that unless you use /EHa, certain destructor cleanups might not
>run when a structured exception (crash) causes the stack to unwind...

See the program below. At least for me (VC++6 running on
W2K), if I compile it in release mode with the /EHa switch
and run it from the command prompt I get:

   Exception
   Done

(I get the same result in debug mode)

On the other hand, if I compile with the (default) /GX
switch and run it from the command prompt, it simply crashes
and exits before it gets a chance to print anything.

#include <windows.h>
#include <iostream>

void RelayException( unsigned int aCode, EXCEPTION_POINTERS* aInfo )
{
     throw "Hmf";
}

int main()
{
     _set_se_translator( RelayException );

     try
     {
         int* test = NULL;
         *test = 42;
     }
     catch( ... )
     {
         std::cout << "Exception" << std::endl;
     }

     std::cout << "Done" << std::endl;

     return 0;
}

-Bill Klein <bill_at_[hidden]>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk