[Issue 15984] Interface contracts retrieve garbage instead of parameters

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon May 2 07:25:16 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=15984

Stewart Gordon <smjg at iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg at iname.com

--- Comment #3 from Stewart Gordon <smjg at iname.com> ---
The posted code doesn't show the problem as I try (DMD 2.071.0 Windows).  In
order to test it, one needs to make sure C's contract fails.  (Though this is
down to another issue, bug 6857.)

But even better would be to add debugging output to I's in contract.

----------
import std.stdio;

interface I
{
    void f(int i)
    in {
        writeln(i);
        assert(i == 5);
    }
}

class C : I
{
    void f(int i)
    in { assert (false); }
    body { }
}

void main()
{
    I i = new C;
    i.f(5);
}
----------
4202755

core.exception.AssertError at bz15984.d(14): Assertion failure
----------------
0x00402D3B
0x00402103
0x00403EA7
0x00403DA8
0x0040270F
0x769DD4D1 in BaseThreadInitThunk
0x77201593 in RtlInitializeExceptionChain
0x77201566 in RtlInitializeExceptionChain
----------

--


More information about the Digitalmars-d-bugs mailing list