[Issue 2697] [DMC too] Cast of float function return to ulong or uint gives bogus value

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Aug 4 00:27:09 PDT 2009


--- Comment #4 from Don <clugdbug at yahoo.com.au>  2009-08-04 00:27:08 PDT ---
The evil is done in cdcnvt() in cod4.c, just after this bit...

        case OPf_d:
        case OPd_f:

        /* if won't do us much good to transfer back and    */
        /* forth between 8088 registers and 8087 registers    */

So it elides the conversion.
This comment, and the transformation it performs, is false in the case where
the OPf_d is followed a conversion from double to uint or ulong (OPd_u32 or
OPd_u64). This is because the C functions which perform the conversion expect
the double to be in EDX:EAX: ie, it genuinely needs to be converted to double.

Conversions from float to uint work on Linux because a different function is
called, which expects the double to be passed in ST0. They work on DMC Windows
because the conversion gets inlined.

Before presenting a patch, I'd like to make sure that there aren't any other
failing cases.

Could someone please check whether conversions from float to ulong work on
(I'm surprised by the comment that it works on Linux, I would expect it to

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