[Issue 3970] New: Problem with cast -1.0L ==> uint/ulong

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Mar 15 11:03:37 PDT 2010


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

           Summary: Problem with cast -1.0L ==> uint/ulong
           Product: D
           Version: 2.041
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2010-03-15 11:03:36 PDT ---
This program compiles and runs with no errors, Don and Aldo Nunez think there
are some inconcistancies here:

void main() {
    static assert((cast(ushort)(-1.0L)) == 0xFFFF);
    static assert((cast(uint)(-1.0)) == 0);
    static assert((cast(uint)(-1.0L)) == 0);
    static assert((cast(ulong)(-1.0L)) == 0xbff0000000000000UL);

    assert((cast(ushort)(-1.0L)) == 0xFFFF);
    assert((cast(uint)(-1.0)) == 0);
    assert((cast(uint)(-1.0L)) == 0);
    assert((cast(ulong)(-1.0L)) == 0xbff0000000000000UL);
}


Don>The cast(uint) case is clearly a bug.<

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