[dmd-internals] [D-Programming-Language/dmd] 29eb97: more 64 bit ABI for structs

Jonathan M Davis jmdavisProg at gmx.com
Thu May 10 19:41:02 PDT 2012


On Wednesday, May 09, 2012 19:33:29 Walter Bright wrote:
> If you could help isolate it down to a test case that does not involve
> std.datetime, I would most appreciate it.

Okay. I finally have the std.datetime breakage reduced to this:

struct S
{
    this(int length)
    {
        _length = length;
    }

    int opBinary(string op)(in S rhs) const
        if(op == "-")
    {
        return this.length - rhs.length;
    }

    @property int length() const
    {
        return _length;
    }

    invariant()
    {
        assert(_length == 1);
    }

    int _length  = 1;
}


void main()
{
    immutable result = S.init - S.init;
}


If you remove the in and const from opBinary and length, it's fine. It's also 
fine if you use this._length - rhs._length instead of using the property. So, 
it's the combination of having const and calling length which breaks it, which 
does look very similar to the problem that core.time was having, so I'm not 
sure if it really helps you as far as the test suite goes. Regardless, it 
_does_ work with the latest head (minus the broken druntime updates), so it's 
been fixed by your recent changes.

- Jonathan M Davis


More information about the dmd-internals mailing list