[Issue 17454] ABI non-conformity: produces unaligned placement of struct on stack

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon May 29 23:45:46 PDT 2017


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

Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla at digitalmars.com

--- Comment #1 from Walter Bright <bugzilla at digitalmars.com> ---
Let's start by compiling the D code, and disassembling d_fun() with obj2asm to
get:

                push    RBP
                mov     RBP,RSP
                sub     RSP,010h
                lea     RCX,[00h][RIP]
                sub     RSP,020h
                call    _d_newclass
                add     RSP,020h
                mov     -8[RBP],RAX
                mov     RAX,-8[RBP]
                mov     RSP,RBP
                pop     RBP
                ret

So RAX becomes the instance of C, and RAX is returned. Nothing wrong with the D
code here. Now looking at the C++ code, it doesn't compile. Adding in the
declaration of d_fun() and disassembling:

                sub     RSP,038h
                lea     RCX,020h[RSP]
                call    d_fun
                add     RSP,038h
                ret

which is what one expects. I don't know where to go from here. Since you say
there is a misalignment, I suggest disassembling the code with the misalignment
in it and seeing if it is on the D side or the C++ side.

--


More information about the Digitalmars-d-bugs mailing list