Can operator delete throw an exception or signal in some other way of error during memory de-allocation?
In other way is it possible for operator delete
to fail and what is it's default behavior in this case?
Also what did ISO standard says about this?
For example in Windows OS - C++ operator new
and operator delete
are normally implemented via functions HeapAlloc
and HeapFree
. The later function returns a boolean value which clearly indicates a fail is possible. Imagine how C++ operator delete
will be written on it:
void operator delete(void *pMem)
{
extern HANDLE hHeap;
extern DWORD dwFlags;
BOOL bSuccee = HeapFree(hHeap, dwFlags, pMem);
//return bSuccee ????????????
}