On Apr 29, 2011, at 11:46 AM, Basile Starynkevitch wrote: > On Fri, 29 Apr 2011 11:08:24 -0400 (EDT) > dnovi...@google.com (Diego Novillo) wrote: > >> This patch from Le-Chun Wu adds support to check whether a nonnull >> attribute is applied to 'this' pointer for non-static methods. > > This bring me to a question. Does the C++ standard imply that this is > never a null pointer?
Does this: 4 Certain other operations are described in this International Standard as undefined (for example, the effect of dereferencing the null pointer). [Note: this International Standard imposes no requirements on the behavior of programs that contain undefined behavior. ] answer your question? Note, this is exactly the same as C. You can't do it in C either: struct A { int x; } *pa = 0; int main() { pa->x = 1; } If you run it, it will crash on all good OSes. In C++, it will also crash.