[Issue 16274] The curses of debugging: short argument passed in 16-bit register, against ABI

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 29 08:35:50 UTC 2020


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

--- Comment #2 from Walter Bright <bugzilla at digitalmars.com> ---
A smaller version:

  extern(C) int init_pair(short pair, short f, short b);
  void test() { init_pair(1, 2, 3); }

which generates:

  _D4testQfFZv:
        push    RBP
        mov     RBP,RSP
        mov     8D,3
        mov     DX,2
        mov     CX,1
        sub     RSP,020h
        call    init_pair
        add     RSP,020h
        pop     RBP
        ret

Indeed, you are correct in that the upper 16 bits of the register is not set.
But I believe this correct code generation. The problem may be in the
implementation of init_pair(), which is assuming the upper 16 bits are zero.

--


More information about the Digitalmars-d-bugs mailing list