[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
Sat Aug 1 03:04:43 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=2697


Don <clugdbug at yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug at yahoo.com.au
            Summary|Cast of float function      |[DMC too] Cast of float
                   |return to ulong or uint     |function return to ulong or
                   |gives bogus value           |uint gives bogus value
           Severity|major                       |critical




--- Comment #3 from Don <clugdbug at yahoo.com.au>  2009-08-01 03:04:42 PDT ---
This code below fails on DMC, proving that this is a severe back-end bug.
Interesting on DMC, the uint case does NOT fail: it inlines in that case.
Raising severity, as I believe this is one of the worse extant compiler bugs.

What's happening is that a function _DBLULNG@ is being used to convert from
double to ulong. It expects a double, but it's being given a float. So garbage
results.

#include <assert.h>
float getFloat() {
    return 5.0f;
}

int main()
{
   unsigned long j = (unsigned long)getFloat();
   assert(j==5);
   return 0;
}

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