www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - DMD 0.112: Class inheriting from another class inheriting from an

reply Burton Radons <burton-radons smocky.com> writes:
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.
Jan 30 2005
parent John Demme <me teqdruid.com> writes:
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.
Jan 30 2005