www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10642] New: Win64: wrong codegen comparing different sized integer arguments

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

           Summary: Win64: wrong codegen comparing different sized integer
                    arguments
           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 09:55:38
PDT ---
Another faiing reduction from the phobos unittests:

import std.stdio;

void _assertEq (ubyte lhs, short rhs, string msg, string file, size_t line)
{
    immutable result = lhs == rhs;

    if(!result)
    {
        string op = "==";
        if(msg.length > 0)
            writefln(`_assertEq failed: [%s] is not [%s].`, lhs, rhs);
        else
            writefln(`_assertEq failed: [%s] is not [%s]: %s`, lhs, rhs, msg);
    }

    assert(result);
}

struct Date
{
    short year;
    ubyte month;
    ubyte day;
}

struct MonthDay
{
    ubyte month;
    short day;
}

unittest
{
    static void test(Date date, int day, MonthDay expected, size_t line =
__LINE__)
    {
        _assertEq(date.day, expected.day, "", __FILE__, line);
    }

    test(Date(1999, 1, 1), 1, MonthDay(1,1));
}

void main() {}

compile with "dmd -O -m64 test.d" produces

_assertEq failed: [208] is not [1]:
core.exception.AssertError test(16): Assertion failure

Checking the disassembly shows that DIL is read in _assertEq, but never
initialized properly. I guess bh was meant instead:

_D4test9_assertEqFhsAyaAyamZv:
  0000000000000000: 55                 push        rbp
  0000000000000001: 48 8B EC           mov         rbp,rsp
  0000000000000004: 48 83 EC 48        sub         rsp,48h
  0000000000000008: 56                 push        rsi
  0000000000000009: 57                 push        rdi
  000000000000000A: 41 54              push        r12
  000000000000000C: 4C 89 45 20        mov         qword ptr [rbp+20h],r8
  0000000000000010: 4C 89 CE           mov         rsi,r9
  0000000000000013: 8A 7D 30           mov         bh,byte ptr [rbp+30h]
  0000000000000016: 44 0F B6 D7        movzx       r10d,dil
  000000000000001A: 44 0F BF DE        movsx       r11d,si
  000000000000001E: 45 3B D3           cmp         r10d,r11d
  0000000000000021: 41 0F 94 C4        sete        r12b
  0000000000000025: 45 0F B6 E4        movzx       r12d,r12b
  0000000000000029: 44 88 65 F0        mov         byte ptr [rbp-10h],r12b

-- 
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=10642



--- Comment #1 from Rainer Schuetze <r.sagitario gmx.de> 2013-07-14 09:57:16
PDT ---
Forgot to add that this only happens with optimizations enabled.

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


Walter Bright <bugzilla digitalmars.com> changed:

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


--- Comment #2 from Walter Bright <bugzilla digitalmars.com> 2013-07-15
16:55:23 PDT ---
 compile with "dmd -O -m64 test.d" produces
Need to add -unittest -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 15 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10642


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         OS/Version|Windows                     |All
           Severity|normal                      |major


--- Comment #3 from Walter Bright <bugzilla digitalmars.com> 2013-07-15
17:48:51 PDT ---
https://github.com/D-Programming-Language/dmd/pull/2349

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



--- Comment #4 from Walter Bright <bugzilla digitalmars.com> 2013-07-16
11:14:50 PDT ---
https://github.com/D-Programming-Language/dmd/pull/2352

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



--- Comment #5 from github-bugzilla puremagic.com 2013-07-16 13:06:42 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/439e85a7ed96dc9eb03a36c967cf854b8e176cf3
fix Issue 10642 - Win64: wrong codegen comparing different sized integer
arguments

https://github.com/D-Programming-Language/dmd/commit/43d47a1dbc378bbeebf7299b2075717f3e6db399
Merge pull request #2352 from WalterBright/fix10642-2

fix Issue 10642 - Win64: wrong codegen comparing different sized integer...

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



--- Comment #6 from github-bugzilla puremagic.com 2013-07-16 13:12:13 PDT ---
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/eab5bf88f306068adff69acf50f7536555f42151
Merge pull request #2352 from WalterBright/fix10642-2

fix Issue 10642 - Win64: wrong codegen comparing different sized integer...

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


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
            Version|D2                          |D1 & D2
         Resolution|                            |FIXED


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