www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10639] New: Win64: wrong optimizer codegen with struct literal with complex fields

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

           Summary: Win64: wrong optimizer codegen with struct literal
                    with complex fields
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          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-14 06:13:54
PDT ---
This source extracted from the phobos unittests:

struct S1 
{ 
    cdouble val; 
}

void formatTest(S1 s, double re, double im)
{
    assert(s.val.re == re);
    assert(s.val.im == im);
}

unittest
{
    S1 s = S1(3+2.25i);
    formatTest(s, 3, 2.25);
}

void main() {}

compile with "dmd -unittest -m64 -O test.d" and run to see the assertions
failing.
This does not happen with -m32 or without -O.

Here is the disassembly of the unittest code:

_D4test15__unittestL12_1FZv:
  0000000000000000: 55                 push        rbp
  0000000000000001: 48 8B EC           mov         rbp,rsp
  0000000000000004: 48 83 EC 10        sub         rsp,10h
  0000000000000008: 48 C7 45 F0 00 00  mov         qword ptr [rbp-10h],0
                    00 00
  0000000000000010: 48 C7 45 F8 00 00  mov         qword ptr [rbp-8],0
                    00 00
  0000000000000018: 4C 8D 45 F0        lea         r8,[rbp-10h]
  000000000000001C: F2 48 0F 10 0D 00  movsd       xmm1,mmword ptr [_TMP3]
                    00 00 00
  0000000000000025: F2 48 0F 10 05 00  movsd       xmm0,mmword ptr [_TMP4]
                    00 00 00
  000000000000002E: 48 83 EC 20        sub         rsp,20h
  0000000000000032: 66 48 0F 7E CA     movd        rdx,xmm1
  0000000000000037: 66 48 0F 7E C1     movd        rcx,xmm0
  000000000000003C: E8 00 00 00 00     call       
_D4test10formatTestFS4test2S1ddZv
  0000000000000041: 48 83 C4 20        add         rsp,20h
  0000000000000045: 48 8D 65 00        lea         rsp,[rbp]
  0000000000000049: 5D                 pop         rbp
  000000000000004A: C3                 ret

The struct literal is initialized with two 0 values at offset 8/10.

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


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com
            Version|D2                          |D1 & D2
         OS/Version|Windows                     |All
           Severity|normal                      |major


--- Comment #1 from Walter Bright <bugzilla digitalmars.com> 2013-07-18
13:18:45 PDT ---
https://github.com/D-Programming-Language/dmd/pull/2359

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



--- Comment #2 from github-bugzilla puremagic.com 2013-07-19 00:11:32 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/a3d33e3937d42fdead489a7f04413583f4451491
fix
Issue 10639 - Win64: wrong optimizer codegen with struct literal with complex
fields

https://github.com/D-Programming-Language/dmd/commit/de687981f72b0256b1dc1233306b4cfe94db626c
Merge pull request #2359 from WalterBright/fix10639

fix Issue 10639 - Win64: wrong optimizer codegen with struct literal with
complex fields

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



--- Comment #3 from github-bugzilla puremagic.com 2013-07-19 14:25:33 PDT ---
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/6f38739b45f65f1173db4401fdb88c583937fd76
Merge pull request #2359 from WalterBright/fix10639

fix Issue 10639 - Win64: wrong optimizer codegen with struct literal with
complex fields

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


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 19 2013