re: I'm not calling a virtual function from my constructor or destructor, but...
Could be worse. At least one compiler would result in calling NULL.
View Articlere: I'm not calling a virtual function from my constructor or destructor, but...
Actually Joshua, I would consider that better. A guaranteed crash right at the point of the problem is always better than undefined behavior that might seem to work sometimes. Actually that would be...
View Articlere: I'm not calling a virtual function from my constructor or destructor, but...
Probably a stupid question (I'm not a C++ expert) but how does an object get destructed when something still has a live reference to it.
View Articlere: I'm not calling a virtual function from my constructor or destructor, but...
@Joshua, @SimonRev: How would you expect a compiler to achieve that? Zero out every object's memory after destruction? That would be a huge performance hit, something you'd only want to do in a debug...
View Articlere: I'm not calling a virtual function from my constructor or destructor, but...
@Mc: Since you state yourself that you are not a C++ expert, will you allow me to guess that your are more familiar with languages with automatic garbage collection, like C# and Java? In C/C++ you must...
View Articlere: I'm not calling a virtual function from my constructor or destructor, but...
@Adam: Exactly, but not quite that extensive. The compiler is already messing with the vtable pointer during destruction. Just have it null out that pointer when destruction is complete. Obviously...
View Articlere: I'm not calling a virtual function from my constructor or destructor, but...
@SimonRev: It filled NULLs into the vtable, so any means of calling a pure virtual function (say indirectly from base class constructor--direct call would be caught by compiler) would call NULL.
View Articlere: I'm not calling a virtual function from my constructor or destructor, but...
Probability this will come in handy at least once in a 40-year career: 80% Probability I will remember this solution: 3% Probability I will vaguely remember Raymond said something interesting about it...
View Articlere: I'm not calling a virtual function from my constructor or destructor, but...
@j b Even in Java or C# this still will happen.
View Articlere: I'm not calling a virtual function from my constructor or destructor, but...
Danny: Are you suggesting that in Java or C# you could reference an object that has already been garbage-collected?
View Articlere: I'm not calling a virtual function from my constructor or destructor, but...
@Joshua -- while I believe it could NULL out the vtable pointer for an object instance, I cannot believe it would fill the vtable itself with NULLs. If it did that, then any live instances of the...
View Articlere: I'm not calling a virtual function from my constructor or destructor, but...
Note that in debug builds the runtime already overwrites freed dynamic memory with `0xdd` bytes (which is even better than setting the memory to zero). I don't think the compiler does anything similar...
View Articlere: I'm not calling a virtual function from my constructor or destructor, but...
Using a replacement memory manager in Delphi (FastMM) we can compile with flags set that - among other useful things - cause the memory manager to write a specific bit pattern over any unallocated...
View Articlere: Command line tool to manage Windows 7 Libraries, with source code
Libraries, that thing in explorer which pushes the ones I want to click out of the view.
View Articlere: I'm not calling a virtual function from my constructor or destructor, but...
@Gabe: well you can access an object that has been 'disposed'. But I believe this is the step just before it gets collected, so technically it's not collected yet.
View Articlere: Well at least nobody's parking there any more
Brian EE: None of the geeks I know have chainsaws that will cut through a 3' tree!
View Articlere: Adventures in undefined behavior: The premature downcast
Yeah I know.... it won't work in a function. I think that should work if it's a class member, though. Just the constructors need to initialize it in the initializer lists. :) I probably should have...
View Articlere: Buzzword-filled subject line easily misinterpreted by unsuspecting manager
In our application there are hierarchical commands, so we often speak about executing children, "the child won't be executed if its younger brother is still running" etc.
View Articlere: You can't rule out a total breakdown of normal functioning, because a...
I think "cosmic radiation" is a bit over... "memory chip went bad" is more plausible explanation.
View Articlere: You can't rule out a total breakdown of normal functioning, because a...
@Raymond >>> "[You're not allowed to jump any stack pages (guard page or otherwise) in Win32, so any compiler that didn't do the chkstk would have crashed even under normal operation....
View Article