digitalmars.D.bugs - [Issue 10633] New: Win64: wrong codegen with %=
- d-bugmail puremagic.com (80/80) Jul 13 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10633
- d-bugmail puremagic.com (10/10) Jul 15 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10633
- d-bugmail puremagic.com (8/8) Jul 15 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10633
- d-bugmail puremagic.com (11/11) Jul 16 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10633
- d-bugmail puremagic.com (9/9) Jul 16 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10633
- d-bugmail puremagic.com (10/10) Jul 16 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10633
http://d.puremagic.com/issues/show_bug.cgi?id=10633 Summary: Win64: wrong codegen with %= Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: r.sagitario gmx.de PDT --- This code crashes when compiled for win64: struct TimeOfDay { void roll(int value) { value %= 60; auto newVal = _seconds + value; if(newVal < 0) newVal += 60; else if(newVal >= 60) newVal -= 60; _seconds = cast(ubyte)newVal; } ubyte _seconds; } void main() { TimeOfDay tod = TimeOfDay(0); tod.roll(-1); assert(tod._seconds == 59); } generated asm for roll: _D4test9TimeOfDay4rollMFiZv: 0000000000000000: 55 push rbp 0000000000000001: 48 8B EC mov rbp,rsp 0000000000000004: 48 83 EC 18 sub rsp,18h 0000000000000008: 53 push rbx 0000000000000009: 48 89 4D 10 mov qword ptr [rbp+10h],rcx 000000000000000D: 89 55 18 mov dword ptr [rbp+18h],edx 0000000000000010: 48 83 7D 10 00 cmp qword ptr [rbp+10h],0 0000000000000015: 75 1D jne 0000000000000034 0000000000000017: 41 B8 03 00 00 00 mov r8d,3 000000000000001D: 48 8D 15 00 00 00 lea rdx,[_TMP1] 00 0000000000000024: 48 8D 0D 00 00 00 lea rcx,[_TMP3] 00 000000000000002B: 48 83 EC 20 sub rsp,20h 000000000000002F: E8 00 00 00 00 call _d_assert_msg 0000000000000034: 41 B9 3C 00 00 00 mov r9d,3Ch 000000000000003A: 8B 45 18 mov eax,dword ptr [rbp+18h] 000000000000003D: 99 cdq 000000000000003E: 41 F7 F9 idiv eax,r9d 0000000000000041: 89 55 18 mov dword ptr [rbp+18h],edx 0000000000000044: 48 8B 5D 10 mov rbx,qword ptr [rbp+10h] 0000000000000048: 0F B6 03 movzx eax,byte ptr [rbx] 000000000000004B: 03 C2 add eax,edx 000000000000004D: 89 45 F8 mov dword ptr [rbp-8],eax 0000000000000050: 85 C0 test eax,eax 0000000000000052: 79 04 jns 0000000000000058 0000000000000054: 01 CD add ebp,ecx 0000000000000056: EB 08 jmp 0000000000000060 0000000000000058: 83 7D F8 3C cmp dword ptr [rbp-8],3Ch 000000000000005C: 7C 02 jl 0000000000000060 000000000000005E: 29 CD sub ebp,ecx 0000000000000060: 8A 55 F8 mov dl,byte ptr [rbp-8] 0000000000000063: 48 8B 4D 10 mov rcx,qword ptr [rbp+10h] 0000000000000067: 88 11 mov byte ptr [rcx],dl 0000000000000069: 5B pop rbx 000000000000006A: 48 8D 65 00 lea rsp,[rbp] 000000000000006E: 5D pop rbp 000000000000006F: C3 ret Notice that the add/sub at offsets 54/5e write to ebp, but the variable is in [rbp-8]. Exchanging "value %= 60;" with "value = value % 60;" fixes the problem. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 13 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10633 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzilla digitalmars.com 02:14:32 PDT --- https://github.com/D-Programming-Language/dmd/pull/2347 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 15 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10633 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |major -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 15 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10633 Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/2f74f0243c3c730c67c6c610d5922008f1121684 fix Issue 10633 - Win64: wrong codegen with %= https://github.com/D-Programming-Language/dmd/commit/70cc17d2132d7dbf7d569ddf0fcbbea58a6c7d76 fix Issue 10633 - Win64: wrong codegen with %= -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 16 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10633 Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/500e1d110dff1c69ee14b671b199f4c44915de86 fix Issue 10633 - Win64: wrong codegen with %= -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 16 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10633 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