I'm working on devirtualization and for that it's crucial to know some spec details (or define them in the spec if they aren't yet).

Currently, calling non-final member functions in the destructor is allowed and these indirect calls are to the possibly overridden functions of derived classes. That is, inside a base class constructor, the object's type is its final type (so possibly of a derived class). This is the same in the destructor. Thus, the object's dynamic type does not change during its lifetime. This greatly simplifies devirtualization, and I want to verify that it is in the spec (I can't find it).

See this example program:
```
char glob;

class A {
    char c;

    this() { c = getType(); }
    ~this() { glob = getType(); }

    char getType() { return 'A'; }
}

class B : A {
    override char getType() { return 'B'; }
}

void main() {
    {
        scope b = new B();
        assert(b.c == 'B');
    }
    assert(glob == 'B');
}
```

My question: where can I find this in the spec, and where in the testsuite is this tested?

If it's not in the spec and/or not in the testsuite, I'll add it.

Thanks,
  Johan

Reply via email to