On 04/29/2011 04:08 PM, Basile Starynkevitch wrote:
[...]
which is also what I expect. I have no idea if it is conforming to
standards. But I notice that the test about this is remaining in the
code. So apparently GCC 4.6 does not make the hypothesis that this is
never null, otherwise it would have optimized the test by removing it.
What I don't know (and I am asking) is if such an hypothetical
optimization is conforming to standards. My biased feeling is that it
is not (because I found no explicit&  unambiguous mention in standard
legal text that this is never null).

9.3.1 seems pretty clear:

If a non-static member function of a class X is called for an object that is 
not of type X, or of a type derived
from X, the behavior is undefined.

A null pointer does not point to an object of type X, so the optimization would be conforming.

Jason

Reply via email to