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

Jonathan M Davis jmdavisProg at gmx.com
Wed May 9 20:06:39 PDT 2012


On Wednesday, May 09, 2012 19:33:29 Walter Bright wrote:
> The failures I've traced back to the guts of std.datetime. I dread those,
> because trying to isolate down 50,000,000,000 lines of endless layers of
> types is several hours of work. The current one I've reduced to:
> 
> import core.stdc.stdio;
> 
> void main()
> {
>          SysTime st = Clock.currTime();
> string s = st._timezone.name;
> printf("_stdTime = x%llx _timezone = %*.s\n", st._stdTime, s.length, s.ptr);
> SysTimeToDosFileTime(st);
> }
> 
> which gives an assert failure in SysTimeToDosFileTime() on 64 bit Linux. So
> far, I have been unable to determine if the corruption is in the value of
> st, or in SysTimeToDosFileTime(). I.e. I cannot figure out of st._stdTime
> or st._timezone is corrupt, or neither. (I made _stdTime and _timezone
> public to help out with this.)
> 
> I do know that the problem is caused somewhere where a struct is passed in a
> register and is expected to have been passed on the stack, or vice versa.
> 
> If you could help isolate it down to a test case that does not involve
> std.datetime, I would most appreciate it.

I'll see what I can do.

druntime is also seeing a failure in core.time, which I can reproduce with 
this:

struct S
{
    this(long length)
    {
        this.length = length;
    }

    long length;
}


const(S) copy(const S s)
{
    return s;
}


void main()
{
    S t = S(42);
    const S u = t;

    assert(t == u);
    assert(copy(t) == u);
    assert(t == copy(u));
}

If I make copy's parameter mutable, it passes. If I change the return type to 
mutable, it still fails. So, it seems to be something related to copy's 
parameter being const. However, the problem also goes away if S's constructor 
is removed, which doesn't appear to have anything to do with const.

I have no idea if this relates to the problem in std.datetime or not, but it 
_is_ a problem only on 64-bit, so it might be related.

- Jonathan M Davis


More information about the dmd-internals mailing list