www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6000] New: Value range propagation does not work with modulus (%) with a constant

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

           Summary: Value range propagation does not work with modulus (%)
                    with a constant
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Mac OS X
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: kennytm gmail.com



Test case:

---------------------------------
void main() {
    ulong t;
    uint v = t & 15;    // ok
    uint u = t % 16;    // error?
}
---------------------------------
x.d(4): Error: cannot implicitly convert expression (t % 16LU) of type ulong to
uint
---------------------------------

There should not be error. The range of "t % 16" is entirely within [0, 15]
which is inside an "uint".

(See also bug 3147)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 14 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6000


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc



A similar case:


void main() {
    long n = 10520;
    ubyte b = n % 10;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 17 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6000


kennytm gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE



*** This issue has been marked as a duplicate of issue 3147 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 12 2011