[Issue 13956] New: 64 bit C ABI not followed for passing empty structs

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Jan 8 08:52:58 PST 2015


https://issues.dlang.org/show_bug.cgi?id=13956

          Issue ID: 13956
           Summary: 64 bit C ABI not followed for passing empty structs
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Keywords: wrong-code
          Severity: major
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: yebblies at gmail.com

Empty structs are allocated a register by dmd, screwing up any subsequent
arguments.

============================================================

#include <stdarg.h>

struct S0 {
};

void checkValues(S0 arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int
arg6);
void cppvararg(S0 arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int
arg6)
{
    checkValues(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
}

============================================================

import core.stdc.stdarg;

struct S0 {
}

extern(C++) void cppvararg(S0 arg0, int arg1, int arg2, int arg3, int arg4, int
arg5, int arg6);

extern(C++) void checkValues(S0 arg0, int arg1, int arg2, int arg3, int arg4,
int arg5, int arg6)
{
    assert(arg0 == S0());
    assert(arg1 == 1);
    assert(arg2 == 2);
    assert(arg3 == 3);
    assert(arg4 == 4);
    assert(arg5 == 5);
    assert(arg6 == 6);
}

void main()
{
    cppvararg(S0(), 1, 2, 3, 4, 5, 6);
}

--


More information about the Digitalmars-d-bugs mailing list