[Issue 5528] New: Some integer interval analysis to avoid some casts

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Feb 5 06:09:25 PST 2011


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

           Summary: Some integer interval analysis to avoid some casts
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2011-02-05 06:07:05 PST ---
This little D2 program shows code that's correct:

void main() {
    uint i = 10;
    ubyte x1 = i % ubyte.max;
    ulong l = 10;
    uint x2 = l % uint.max;
}


But dmd 2.051 asks for casts:
test.d(3): Error: cannot implicitly convert expression (i % 255u) of type uint
to ubyte
test.d(5): Error: cannot implicitly convert expression (l % 4294967295LU) of
type ulong to uint

I think those casts are not necessary, so I'd like dmd to avoid asking for
casts in such situations.

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