Are there tools to catches deletion of a stack object, how likely that gcc and Visual Studio debug build will break on that event immediately?
I deal with big, old projects, so that is not a question on how to write code, but how to detect and fix problems.
Most of the heap implementations are not tolerate to invalid pointers (i.e. when you
deletean address which was not returned to you by the heap). Almost for sure standard windows heap, and CRT’s heap (implemented by MSVC) cause a debug breakpoint in such a case.You may also replace the implementation of
new/deleteoperators and do the checking yourself (in your case you only want to check if the address belongs to the stack memory, which is easy).