Automatic invariant generation

Stefan Koch via Digitalmars-d digitalmars-d at puremagic.com
Fri Jul 7 01:24:22 PDT 2017


On Friday, 7 July 2017 at 08:21:50 UTC, 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;
> }
>
> I tried disabling the invariant but it complained that 
> invariant requires a function body.
> Is there a way to disable the implicit generations of 
> invariants for my code other than -release? Like for a 
> particular subset of files (separate invocations of the 
> compiler is not an acceptable approach.
>
> The reason being that I do not support global variables (of any 
> kind) at the moment in dcompute and the insertion of the string 
> literal to the assert breaks that.

Looks like you'd need to do your own hack to disable this 
particular assert.
When it's used in a dcompute-context.


More information about the Digitalmars-d mailing list