[cfe-commits] r145575 - in /cfe/trunk: lib/StaticAnalyzer/Core/ExprEngine.cpp test/Analysis/misc-ps-region-store.cpp

John McCall rjmccall at apple.com
Mon Dec 12 10:04:00 PST 2011

On Dec 11, 2011, at 11:53 AM, Richard Smith wrote:
> On Sun, December 11, 2011 08:15, Jonathan Sauer wrote:
>>> Hi, Ted. Just wanted to note that it's technically legal for 'this' to be
>>> null if the method is non-virtual, which I'm sure you know already. Maybe
>>> someday we can make this a setting?
>> I'm not so sure about that. After all, when calling the method as in
>> "obj->method()", you dereference the pointer. And
>> dereferencing a NULL pointer results in undefined behaviour.
> That is a controversial position. My understanding is that the intent of the
> committee is that dereferencing a null pointer is not undefined behaviour; an
> lvalue-to-rvalue conversion on the result is, as is binding a reference to
> such a value.

One interesting problem with this interpretation (which generally comports
with my understanding of the committee's intent as well, but…) is that
non-static data member accesses should clearly only be well-defined if
the base is an object and has the right type, and yet there doesn't appear
to be anything saying that in the standard unless l-values are generally
constrained to so refer.

Unless they've once again placed this in some incredibly unobvious

At any rate, I think we can agree that calling a non-static member
function with a null object is undefined behavior, no matter how we get


More information about the cfe-commits mailing list