Bug 6875 – floating point %= trashes register EAX

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2011-11-01T11:41:00Z
Last change time
2015-06-09T05:10:42Z
Keywords
pull, wrong-code
Assigned to
yebblies
Creator
r.sagitario

Comments

Comment #0 by r.sagitario — 2011-11-01T11:41:12Z
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]
Comment #1 by yebblies — 2012-02-24T02:24:04Z