null this, classes, methods and "null this" assertion

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 10 19:49:07 PDT 2015


On 4/10/15 10:17 PM, ketmar wrote:
> On Fri, 10 Apr 2015 22:06:53 -0400, Steven Schveighoffer wrote:
>
>> In non-release mode, it's calling the invariant, which is a virtual
>> function.
>
> yet compiler can generate `CondExp` instead of `AssertExp`, and don't
> fail when `this` is `null`.
>

A virtual function cannot be called on a null pointer. I would have 
actually expected it to crash, but maybe it does something special for 
invariant.

-Steve


More information about the Digitalmars-d mailing list