Thread overview
[Issue 14865] Elide calling invariant for classes with no invariant defined
Aug 04, 2015
Kenji Hara
Aug 04, 2015
Dmitry Olshansky
Dec 17, 2022
Iain Buclaw
August 03, 2015
https://issues.dlang.org/show_bug.cgi?id=14865

Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy@yahoo.com

--
August 04, 2015
https://issues.dlang.org/show_bug.cgi?id=14865

--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> ---
For virtual class methods, their invariant call should be virtual. For example:

class C
{
    void foo() {}
}

class D : C
{
    invariant {}
}

void main()
{
    C c = new D;
    c.foo();    // should check D.invariant
}

--
August 04, 2015
https://issues.dlang.org/show_bug.cgi?id=14865

--- Comment #2 from Dmitry Olshansky <dmitry.olsh@gmail.com> ---
(In reply to Kenji Hara from comment #1)
> For virtual class methods, their invariant call should be virtual. For example:
> 
> class C
> {
>     void foo() {}
> }
> 
> class D : C
> {
>     invariant {}
> }
> 
> void main()
> {
>     C c = new D;
>     c.foo();    // should check D.invariant
> }

Could it do a test on invariant v-table slot to see if it's a default
invariant?
Then if it's the default - just test for null inline, if not - call that slot.

--
August 04, 2015
https://issues.dlang.org/show_bug.cgi?id=14865

--- Comment #3 from Steven Schveighoffer <schveiguy@yahoo.com> ---
(In reply to Dmitry Olshansky from comment #2)
> Could it do a test on invariant v-table slot to see if it's a default
> invariant?
> Then if it's the default - just test for null inline, if not - call that
> slot.

Yes, that's exactly what I meant. In fact, the language could put a null pointer in that slot by default to make it easy. Although I don't understand what you mean by the "test for null inline". If the object is null, there is no vtable to check.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=14865

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P4

--
December 13
https://issues.dlang.org/show_bug.cgi?id=14865

--- Comment #4 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/17718

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--