www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - invariant bug or documentation error.

reply "Dave" <Dave_member pathlink.com> writes:
Private member g() in an invariant block causes a stack overflow, contrary 
to the doc.: http://digitalmars.com/d/class.html

class Foo
{
    int i = 10;
    private int g() { return i = 1; }
    this(){}
    invariant
    {
        g(); // Causes Stack Overflow after constructor is called
        assert(i >= 10);
    }
}

void main()
{
    Foo f = new Foo();
    assert(f); // or when this is executed
    f.g();       // or when this is called.
}
Feb 05 2005
next sibling parent Dave <Dave_member pathlink.com> writes:
This applies to dmd v0.111.

In article <cu30gc$29cb$1 digitaldaemon.com>, Dave says...
Private member g() in an invariant block causes a stack overflow, contrary 
to the doc.: http://digitalmars.com/d/class.html

class Foo
{
    int i = 10;
    private int g() { return i = 1; }
    this(){}
    invariant
    {
        g(); // Causes Stack Overflow after constructor is called
        assert(i >= 10);
    }
}

void main()
{
    Foo f = new Foo();
    assert(f); // or when this is executed
    f.g();       // or when this is called.
}

Feb 05 2005
prev sibling parent Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dave schrieb am Sat, 5 Feb 2005 11:43:33 -0600:
 Private member g() in an invariant block causes a stack overflow, contrary 
 to the doc.: http://digitalmars.com/d/class.html

 class Foo
 {
     int i = 10;
     private int g() { return i = 1; }
     this(){}
     invariant
     {
         g(); // Causes Stack Overflow after constructor is called
         assert(i >= 10);
     }
 }

 void main()
 {
     Foo f = new Foo();
     assert(f); // or when this is executed
     f.g();       // or when this is called.
 }

Added to DStress as http://dstress.kuehne.cn/run/invariant_19.d http://dstress.kuehne.cn/run/invariant_20.d http://dstress.kuehne.cn/run/invariant_21.d http://dstress.kuehne.cn/run/invariant_22.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCBf073w+/yD4P9tIRAsoAAJ4k1hQqgPd9b0fWTgR3PWKgzo9JoQCfXMnx WDW/MkhZ5PQ+D80YqF5Nyz8= =62nc -----END PGP SIGNATURE-----
Feb 06 2005