|
From: | Olivier DERVYN |
Subject: | Exception in delete operator |
Date: | Thu, 4 Jul 2002 09:27:09 +0200 |
Exception is not
rethrow form overloaded delete operator
Her e a short form of my code :
void operator delete( void * ptrMemory )
throw()
{ try { if( mg_nStatus ) { BlockFree( ptrMemory ); mg_nStatus--; } else BlockFree( ptrMemory ); } catch( MemoryException * e ) { throw e; } } bool
MG_MisMatchAlloc1()
{ char * buf1 = new char[5]; // use delete in place of
delete[]
try { delete buf1; } catch( MemoryException * e ) { delete e; delete [] buf1; return true; } catch( ... ) { delete [] buf1; return true; } return
false;
} MG_MisMatchAlloc1() call "delete buf1" in place of
"delete [] buf1" my operator delete
is called, then BlockFree (my memory handler) is
called too.
BlockFree generate an exception, exception is
caught in operator delete but not rethrow.
Default exception handler is called instead of my
catch section (for test reason, I have added a catch all section).
Please, anybody can confirm this problem and send
me a workaround.
Regards, Olivier
|
stack.jpg
Description: JPEG image
[Prev in Thread] | Current Thread | [Next in Thread] |