January 31, 2005 DMD 0.112: Class inheriting from another class inheriting from an interface and another interface and oh just look at the example | ||||
---|---|---|---|---|
| ||||
This one's a killer to explain. The following code should print 1; instead it prints 0. This is apparently caused by too many inherited instances of A, with one reference to the object getting one indexed pointer and the other object getting the other for whatever reason. So when the equivalency operator attempts to align the two instances, it gets two different pointers and bails. interface A { void call (A other); } interface Ab : A { } class B : A { void call (A other) { printf ("%d\n", this === other); } } class C : B, Ab { } void main () { C b = new C (); b.call (b); } I can work around the problem. |
January 31, 2005 Re: DMD 0.112: Class inheriting from another class inheriting from an interface and another interface and oh just look at the example | ||||
---|---|---|---|---|
| ||||
Posted in reply to Burton Radons | Yeah... I've already posted about this one. It's in DStress. See "=== No Damn Good"
Burton Radons wrote:
> This one's a killer to explain. The following code should print 1; instead it prints 0. This is apparently caused by too many inherited instances of A, with one reference to the object getting one indexed pointer and the other object getting the other for whatever reason. So when the equivalency operator attempts to align the two instances, it gets two different pointers and bails.
>
> interface A
> {
> void call (A other);
> }
>
> interface Ab : A
> {
> }
>
> class B : A
> {
> void call (A other)
> {
> printf ("%d\n", this === other);
> }
> }
>
> class C : B, Ab
> {
> }
>
> void main ()
> {
> C b = new C ();
>
> b.call (b);
> }
>
> I can work around the problem.
|
Copyright © 1999-2021 by the D Language Foundation