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: nob...@puremagic.com ReportedBy: r.sagita...@gmx.de --- Comment #0 from Rainer Schuetze <r.sagita...@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: -------