Automatic invariant generation

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Fri Jul 7 06:34:20 PDT 2017


On 7/7/17 4:21 AM, Nicholas Wilson wrote:
> The compiler seems to inset an `assert(this !is null, "null this");` 
> into my struct.
> which is for all intents and purposes.
> struct Foo {
>      Bar b;
> }
> 
> struct Bar {
>      void* ptr;
> }

What? When is this invariant called? I've never heard of a hidden 
invariant being added to structs, structs are supposed to be free of 
such things.

I would call such a thing a bug.

-Steve


More information about the Digitalmars-d mailing list