14 Mar, 2009, David Haley wrote in the 2nd comment:
Votes: 0
Well, I have occasionally seen methods called with a NULL 'this' – it depends on whether the compiler can know what type the pointer is exactly and whether it needs to go to a vtable and so forth. I don't guard against NULL 'this' pointers myself. I consider that you should only call a method on something if you know it's non-NULL, and if you do, you are doing something Very Wrong (TM) and should crash immediately so that you can track it down.
In general, this is never NULL. If it is, there is a more fundamental problem, such as an attempt to call a method on a NULL pointer (which will crash if the method is virtual anyway) or more commonly some kind of memory corruption. Calling a method on a NULL pointer is undefined behavior in the C++ specification.
Do you need to check 'this' inside of the function fxn, or merely by the fact that you can do blah->fxn(), does it mean that 'this' is not NULL.
So what I mean, is do I need something like:
Thanks,
KeB