static weirdness

Jonathan M Davis newsgroup.d at jmdavisprog.com
Thu Jan 25 12:43:19 UTC 2018


On Thursday, January 25, 2018 12:38:25 Kagamin via Digitalmars-d-learn 
wrote:
> On Thursday, 25 January 2018 at 12:06:07 UTC, Jonathan M Davis
>
> wrote:
> > Actually, assert on a pointer to a struct or a reference to a
> > class checks for null _and_ calls the invariant, and that
> > hasn't changed. But you have to actually assert the pointer or
> > reference if you want to do that, and the OP didn't do that. He
> > asserted whether it == null.
>
> I mean the compiler implicitly inserted a check like:
> struct S
> {
>      auto fun()
>      {
>       assert(&this!=null);
>       return 42;
>      }
> }

AFAIK, it has never done that. Walter's stance on null pointers has always
been that that's what segfaults are for, and he's against adding any
additional null checks.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list