[Issue 14456] New: dmd doesn't call C functions with large structures correctly
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Fri Apr 17 06:26:52 PDT 2015
    
    
  
https://issues.dlang.org/show_bug.cgi?id=14456
          Issue ID: 14456
           Summary: dmd doesn't call C functions with large structures
                    correctly
           Product: D
           Version: D1
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: andrew.stevenson at sociomantic.com
Created attachment 1513
  --> https://issues.dlang.org/attachment.cgi?id=1513&action=edit
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;
--
    
    
More information about the Digitalmars-d-bugs
mailing list