newCTFE Status Janurary 2018

Stefan Koch uplink.coder at googlemail.com
Sat Jan 26 21:52:58 UTC 2019


On Sunday, 13 January 2019 at 14:47:59 UTC, Stefan Koch wrote:
> [ ... ]

Another small update: I've just fixed problems with 
class-constructor and vtbl handling.
meaning the following code does compile now.

class B {}
class C : B
{
   int _i = 2;
   int i() {return ( 1); }
}
class D : C
{
   override int i() {return 2;}
   float f() { return 1.0f; }
}
class E : D
{
   int _x;
   this(int _x)
   {
     this._x = 3;
   }
   override int i() {return _x;}
   override float f() { return 2.0f; }
}
int testClassStuff ()
{
   B b1;
   C c1, c2, c3;
   D c4;
   c1 = new C();
   c2 = new D();
   c3 = new E(3);
   b1 = new D();

   D e = new E(3);
   assert(cast(int)e.f() == 2);
   assert(c2 is c2, "Identity is broken ?");
   assert((cast(D)c3), "Dynamic cast not working");
   assert(!(cast(E)c2), "Dynamic cast not working");
   assert((cast(C)b1), "Dynamic cast not working");

   return c1.i + c2.i + c3.i;
}
static assert(testClassStuff == 1 + 2 + 3);
// the second static assert used to fail, because of stale vtbl 
pointers.
static assert(testClassStuff == 1 + 2 + 3);
static assert(testClassStuff == 1 + 2 + 3);

--

Cheers,

Stefan


More information about the Digitalmars-d mailing list