Bug 14456 – (D1 only) dmd doesn't call C functions with large structures correctly

Status
RESOLVED
Resolution
WONTFIX
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86_64
OS
Linux
Creation time
2015-04-17T13:26:52Z
Last change time
2019-11-07T08:01:54Z
Keywords
industry, wrong-code
Assigned to
No Owner
Creator
Andrew Stevenson

Attachments

IDFilenameSummaryContent-TypeSize
1513dmd_64bit_struct.tar.xzexample codeapplication/x-xz1136

Comments

Comment #0 by andrew.stevenson — 2015-04-17T13:26:52Z
Created attachment 1513 example code On Linux/amd64 an argument to a C function which is a structure larger than 64 bits should be passed across multiple registers. Making this call with DMD however does something else (probably trying to pass on the stack). I attach some example code to demonstrate the problem. "make c" produces a binary from C code and "make d" produces a binary from D calling into C. Both should produce the same output. I currently use a workaround of calling the C function via inline ASM. The correct ASM for the attached example would be something like: mov RDI, qword ptr a; mov RSI, qword ptr a + 8; call prettify;
Comment #1 by andrew.stevenson — 2015-04-17T13:28:59Z
This will probably be a specific case of https://issues.dlang.org/show_bug.cgi?id=5570
Comment #2 by yebblies — 2015-04-18T04:07:54Z
Which compiler version? DMD 2.067 has several fixes in this area thanks to fuzz testing.
Comment #3 by andrew.stevenson — 2015-04-20T10:14:33Z
v1.077.s12
Comment #4 by yebblies — 2015-04-20T10:41:02Z
That makes more sense.
Comment #5 by razvan.nitu1305 — 2019-11-07T08:01:54Z
Closing as D1 is no longer supported.