Bug 13956 – 64 bit C ABI not followed for passing empty structs
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2015-01-08T16:52:00Z
Last change time
2015-02-18T03:42:13Z
Keywords
pull, wrong-code
Assigned to
yebblies
Creator
yebblies
Comments
Comment #0 by yebblies — 2015-01-08T16:52:58Z
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);
}