Doing some experiments, and after conversion of struct into a class I've found 
that opAssign(), contrary to what documentation says, is silently accepted for 
classes (in D 2.052)

What is worse, it segfaults when object is not constructed first:

---snip---
class X {
        int     v;

        typeof(this) opAssign(int i)
        {
                v = i;
                return this;
        }
}

void main()
{
        X x0 = new X();
        x0 = 0;                 // ok
        X x1 = 0;               // segfault
}
---snip--

Well, I understand why it segfaults, but shouldn't opAssign() be disallowed? If 
documentation is wrong, and it is still valid for classes, this should be 
handled somehow else.

/Alexander

Reply via email to