--- Begin Message ---
- From: Abhishek Pamecha <apamecha at houston dot geoquest dot slb dot com>
- To: Ganeshmurthy Patil <gpatil at houston dot geoquest dot slb dot com>,Arnab Nandi <anandi at houston dot geoquest dot slb dot com>,Suresh Govindaraju <sgovindaraju at slb dot com>
- Date: Thu, 28 Aug 2003 18:01:03 +0200
- Subject: null pointer dereferencing
- Organization: Schlumberger
class A{
public:
A() {}
~A() {}
void do_something(void){}
int b;
};
int main(){
A *a = 0;
//null pointer dereferencing!!!!!
a->do_something();
// a->b = 10; fails though
return 0;
}
this code works! Ganesh, this is similar to the strat log code that had
same problem (CreateComp_dialog.cc) (suresh told me about it).
Only reason I can attribute to it is that the method is not changing the
state of the object and a method belongs 'more' to a class than to an
object. The compiler might have generated such a nasty side effect by
replacing the statement by a direct call to the func instead of first
de-referencing it in runtime. From a language point of view, it seems
incorrect to me.
Can you provide different reasons why it should work the way it is?
thanks
Abhishek
--- End Message ---