RE: [Dev-C++] Constructor and Destructor
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Per W. <pw...@ia...> - 2003-07-10 18:37:30
|
It depends on luck. An uninitialized pointer may point anywhere in memory. Since in this case the pointer was allocated on the stack in main(), there is a big possibility that it will get a non-random value from the initialization code. A protected-mode program may only kill the program if the pointer access is outside of the memory allowed to the program, to protect other programs. The compiler would have to insert extra code - not all compilers supports extra debugging instrumentation for run-time data checking - to keep track of uninitialized values and what a pointer may or may not be used for. A protected mode system is not built for sw debugging, i.e. to make sure that a program is bug-free. /Per W On Thu, 10 Jul 2003, Abhijit Shylanath wrote: > > > When you don't assign a value to b it will be uninitialized, and set to > > any value that might be in memory. When you then call a non-virtual method > > of the object, the method will thus get a random 'this' pointer. > > But shouldn't a protected-mode program crash when you try to access a > pointer that doesn't point to legally allocated memory? > > -- > Abhijit Shylanath > Homepage: http://mudeth.tripod.com/ > > > > ------------------------------------------------------- > This SF.Net email sponsored by: Parasoft > Error proof Web apps, automate testing & more. > Download & eval WebKing and get a free book. > www.parasoft.com/bulletproofapps1 > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |