www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9107] New: Value Range Analysis with uint and byte

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

           Summary: Value Range Analysis with uint and byte
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



Maybe this shows a problem of the Value Range Analysis, DMD 2.061alpha;


void main(string[] args) {
    int a1 = 198 + args.length; // A run-time value.
    byte b1 = a1 % 200;  // error, OK.

    uint a2 = 198 + args.length;
    ubyte b2 = a2 % 200;  // no error, good.
    byte b3 = a2 % 200;  // no error, bad.
}


test.d(3): Error: cannot implicitly convert expression (a1 % 200) of type int
to byte

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 02 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9107


yebblies <yebblies gmail.com> changed:

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



Range of a2 % 200: ( 0 to 200 )
Range of byte: ( -128 to 127 )

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 16 2013