www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10677] New: Win64: cfloat return value not forwarded correctly as function argument

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10677

           Summary: Win64: cfloat return value not forwarded correctly as
                    function argument
           Product: D
           Version: D1 & D2
          Platform: x86_64
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: r.sagitario gmx.de


--- Comment #0 from Rainer Schuetze <r.sagitario gmx.de> 2013-07-20 00:57:23
PDT ---
Another one from the phobos unittests that I hoped was covered by other
reports:

///////////////////////////////

void formatTest2(cfloat s, double re, double im)
{
    assert(s.re == re);
    assert(s.im == im);
}

cfloat getcf()
{
    return 2 + 1i;
}

unittest
{
    formatTest2( getcf(), 2, 1 );
}

void main() {}

//////////////////////////////

compile with "dmd -m64 -unittest test.d" to trigger the assertion.

Here's the disassembly:

_D4test5getcfFZq:
  0000000000000000: 55                 push        rbp
  0000000000000001: 48 8B EC           mov         rbp,rsp
  0000000000000004: 48 83 EC 10        sub         rsp,10h
  0000000000000008: D9 05 00 00 00 00  fld         dword ptr [_TMP0]
  000000000000000E: D9 05 04 00 00 00  fld         dword ptr [_TMP0+4]
  0000000000000014: D9 5D F0           fstp        dword ptr [rbp-10h]
  0000000000000017: F3 0F 10 4D F0     movss       xmm1,dword ptr [rbp-10h]
  000000000000001C: D9 5D F0           fstp        dword ptr [rbp-10h]
  000000000000001F: F3 0F 10 45 F0     movss       xmm0,dword ptr [rbp-10h]
  0000000000000024: 48 8D 65 00        lea         rsp,[rbp]
  0000000000000028: 5D                 pop         rbp
  0000000000000029: C3                 ret

_D4test15__unittestL13_1FZv:
  0000000000000000: 55                 push        rbp
  0000000000000001: 48 8B EC           mov         rbp,rsp
  0000000000000004: 48 83 EC 10        sub         rsp,10h
  0000000000000008: 48 83 EC 20        sub         rsp,20h
  000000000000000C: E8 00 00 00 00     call        _D4test5getcfFZq
  0000000000000011: 48 83 C4 20        add         rsp,20h
  0000000000000015: 49 89 C0           mov         r8,rax
  0000000000000018: F2 48 0F 10 0D 00  movsd       xmm1,mmword ptr [_TMP1]
                    00 00 00
  0000000000000021: 48 B8 00 00 00 00  mov         rax,3FF0000000000000h
                    00 00 F0 3F
  000000000000002B: 48 89 45 F0        mov         qword ptr [rbp-10h],rax
  000000000000002F: F2 0F 10 45 F0     movsd       xmm0,mmword ptr [rbp-10h]
  0000000000000034: 48 83 EC 20        sub         rsp,20h
  0000000000000038: 66 48 0F 7E CA     movd        rdx,xmm1
  000000000000003D: 66 48 0F 7E C1     movd        rcx,xmm0
  0000000000000042: E8 00 00 00 00     call        _D4test11formatTest2FqddZv
  0000000000000047: 48 83 C4 20        add         rsp,20h
  000000000000004B: 48 8D 65 00        lea         rsp,[rbp]
  000000000000004F: 5D                 pop         rbp
  0000000000000050: C3                 ret

getcf returns the result in xmm0 and xmm1, but it is expected in rax by the
caller.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 20 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10677


Walter Bright <bugzilla digitalmars.com> changed:

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


--- Comment #1 from Walter Bright <bugzilla digitalmars.com> 2013-07-20
21:11:32 PDT ---
https://github.com/D-Programming-Language/dmd/pull/2371

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 20 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10677



--- Comment #2 from github-bugzilla puremagic.com 2013-07-21 23:36:46 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/dcebbd99140bcec147522be779cdc00af8fc70ff
fix Issue 10677 - Win64: cfloat return value not forwarded correctly as
function argument

https://github.com/D-Programming-Language/dmd/commit/bbcd96872ea1afe719adf97675985517217837fa
Merge pull request #2371 from WalterBright/fix10677

fix Issue 10677 - Win64: cfloat return value not forwarded correctly as ...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 21 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10677


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 22 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10677



--- Comment #3 from github-bugzilla puremagic.com 2013-07-22 11:51:00 PDT ---
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/f70a40257e73fcd6e37e7208776b29e1e5d2f6aa
Merge pull request #2371 from WalterBright/fix10677

fix Issue 10677 - Win64: cfloat return value not forwarded correctly as ...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 22 2013