[Issue 6875] New: floating point %= trashes register EAX

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Nov 1 11:42:27 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6875

           Summary: floating point %= trashes register EAX
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: r.sagitario at gmx.de


--- Comment #0 from Rainer Schuetze <r.sagitario at gmx.de> 2011-11-01 11:41:12 PDT ---
With dmd 2.056:

void main()
{
    float g = 4;
    float f = 4;
    float *p = &f;
    *p %= g;
    assert(f == 0);
}

causes a crash at runtime or the assertion to fail.

This is caused by the %= implementation changing the AX register unexpectedly:


    float *p = &f;
0040201E  lea         eax,[f] 
00402021  mov         dword ptr [p],eax 
    *p %= g;
00402024  mov         ecx,dword ptr fs:[2Ch] 
0040202B  mov         edx,dword ptr [ecx] 
0040202D  fld         dword ptr [edx+4] 
00402033  fld         dword ptr [eax] 
00402035  fprem            
00402037  fnstsw      ax   
00402039  sahf             
0040203A  jp          D main+25h (402035h) 
0040203C  fstp        st(1) 
0040203E  fstp        dword ptr [eax]

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


More information about the Digitalmars-d-bugs mailing list