www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7734] New: Wrong comparison of float return value from opEquals

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7734

           Summary: Wrong comparison of float return value from opEquals
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: simen.kjaras gmail.com



PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 19 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7734


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies gmail.com



Huh?  Isn't it just loading the fpu status bits then branching if not equal?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 20 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7734


Simen Kjaeraas <simen.kjaras gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID



PDT ---
Yups. My brain was somewhere else when I filed this. Closing it as invalid.

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