|
From: Ioannis V. <no...@ho...> - 2002-04-08 16:17:33
|
-----Original Message----- From: dev...@li... [mailto:dev...@li...] On Behalf Of Bob Wilson Sent: Monday, April 08, 2002 6:02 PM To: fee...@sa...; Dev-C++ User Mailing List Subject: [Dev-C++] Deliberate crashes I have several questions. How could someone who is expert enough to write a beginning book on C++ make such an error Deleting the contents of an invalid memory address (that is a memory address where there is no space allocated by new) invokes undefined behavior. Undefined behavior can be the program crashes, the OS crashes, the airplane falls, the robotic arm destroyes the machine. In your case the program does not crash but some other damage occurs (some contents of another thing are altered (e.g. of a function) or it can be that delete knows that it has erased the contents of that memory and doesn't clear them again. In any case it just *happened* to not crash your program immediately. 1. Is it perhaps because the ANSI/ISO definition of the language and what a compiler should do has changed? No. 1. Have GNU and the Gates crowd made similar unilateral changes to solve a pesky problem? It can be that some particular compiler take care of that but you can't rely on this. 1. Did I misread something which seems fairly straight forward? 2. Are there other pointer inconsistances hiding in the weeds waiting to pounce on the unsuspecting? Yes the problem may appear later. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.cjb.net <http://www.noicys.cjb.net/> * Alternative URL: http://run.to/noicys |