www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6875] New: floating point %= trashes register EAX

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: r.sagitario gmx.de



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: -------
Nov 01 2011
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6875


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
            Version|unspecified                 |D1 & D2
           Keywords|                            |pull
           Platform|Other                       |x86
                 CC|                            |yebblies gmail.com
         AssignedTo|nobody puremagic.com        |yebblies gmail.com
         Resolution|                            |FIXED
         OS/Version|Windows                     |All



Fixed in 2.059/1.073 head

https://github.com/D-Programming-Language/dmd/pull/759

https://github.com/D-Programming-Language/dmd/commit/1d1bc367c131144e764d9fb81c36651407e3337d

https://github.com/D-Programming-Language/dmd/commit/9fcab1292ec59b04a458f9ccc90736c500a52bf3

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