Crash in out contract in interface

Alex Rønne Petersen xtzgzorex at gmail.com
Wed Aug 24 06:13:41 PDT 2011


Hi,

This is an odd one. Consider the following code:

> interface I
> {
>     void foo()
>     out { assert(bar()); }
>     bool bar();
> }
>
> class C : I
> {
>     void foo() {}
>     bool bar() { return true; }
> }
>
> void main()
> {
>     C c = new C();
>     c.foo();
> }

This will crash and burn when run:

> object.Error: Access Violation
> ----------------
> 40DB64
> 40D9DB
> 402050
> 402074
> 4026F3
> 4022EF
> 4127B5
> ----------------

I assume this is a bug, but has anyone encountered this before or have 
any idea why exactly it happens when calling other interface methods in 
an interface method's out contract? (It seems to work fine in the in 
contract.)

- Alex


More information about the Digitalmars-d mailing list