www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Crash on static const struct instances

The following code crashes DMD 0.101 on Windows XP:

-------------------

struct Foo {
   static const Foo JOHN;
}

void main()
{
   Foo bar = Foo.JOHN;
}

-------------------

I was just converting some C++ code where static const values like this 
where used as default or special values that a struct/class could have. 
I suppose other solutions are possible, but not quite as elegant.

void foo(Foo val = Foo.JOHN)
{
   if (val is Foo.JOHN) {
     ..
   }
   else {
     ...
   }
}


Lars Ivar Igesund
Sep 18 2004