Bug 7734 – Wrong comparison of float return value from opEquals

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-03-19T10:57:00Z
Last change time
2012-03-21T08:44:51Z
Keywords
wrong-code
Assigned to
nobody
Creator
simen.kjaras

Comments

Comment #0 by simen.kjaras — 2012-03-19T10:57:24Z
struct Foo { float opEquals(int other) { return 0.0; } } void main( ) { assert( Foo() != 3 ); } The above code generates this assembly: fldz fucompp fnstsw ax sahf je D main+25h mov eax,0Ah call main@__assert It seems to assume that FPU status flags will be all 0 when the return value is 0.0, which is simply not true - the C3 flag is 1 when the return value is 0.0.
Comment #1 by yebblies — 2012-03-20T22:45:49Z
Huh? Isn't it just loading the fpu status bits then branching if not equal?
Comment #2 by simen.kjaras — 2012-03-21T08:44:51Z
Yups. My brain was somewhere else when I filed this. Closing it as invalid.