Exception problem
-
I'm not expert on exceptions. I need to catch some memory exception and ignore it, but it des not work. It only works in debug release (exception is ignored), but in release mode it crashes like when I don't handle the exception. What is the problem? Here is code :
try { \*((char\*)0)=1; } catch(...) { }
It is MFC app in VC6.0. Thank you.
-
I'm not expert on exceptions. I need to catch some memory exception and ignore it, but it des not work. It only works in debug release (exception is ignored), but in release mode it crashes like when I don't handle the exception. What is the problem? Here is code :
try { \*((char\*)0)=1; } catch(...) { }
It is MFC app in VC6.0. Thank you.
This is the difference between C++ typed exceptions and Win32 structured exceptions. What you have is the former. See
_set_se_translator()
for more."Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
-
This is the difference between C++ typed exceptions and Win32 structured exceptions. What you have is the former. See
_set_se_translator()
for more."Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
-
Thank you. I'm going to check it. I wonder why debug mode caught the exception. Does debug mode use some default translator?
rrrado wrote:
I wonder why debug mode caught the exception.
I'm really not sure, but it may have to do with the optimizer.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
-
I'm not expert on exceptions. I need to catch some memory exception and ignore it, but it des not work. It only works in debug release (exception is ignored), but in release mode it crashes like when I don't handle the exception. What is the problem? Here is code :
try { \*((char\*)0)=1; } catch(...) { }
It is MFC app in VC6.0. Thank you.
In C++ - assuming the implementation follows the standard -
catch
is only allowed to catch exceptions raised using thethrow
keyword: since this isn't the case in your example the code in thecatch
block should NOT be executed. MSVC6 got this wrong but the bug has been corrected in later versions. The /EH[^] switch can be used to reinstate the bug.Steve
-
I'm not expert on exceptions. I need to catch some memory exception and ignore it, but it des not work. It only works in debug release (exception is ignored), but in release mode it crashes like when I don't handle the exception. What is the problem? Here is code :
try { \*((char\*)0)=1; } catch(...) { }
It is MFC app in VC6.0. Thank you.
-
Thank you. I'm going to check it. I wonder why debug mode caught the exception. Does debug mode use some default translator?
rrrado wrote:
I wonder why debug mode caught the exception
Might be because you set the "Enable C++ Exception=> YES with Structured exception (/EHa)" for debug configuration settings but not for release configuration.