Thread overview
[Issue 6000] New: Value range propagation does not work with modulus (%) with a constant
May 14, 2011
kennytm@gmail.com
Jun 12, 2011
kennytm@gmail.com
May 14, 2011
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


--- Comment #0 from kennytm@gmail.com 2011-05-14 08:05:03 PDT ---
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 17, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6000


bearophile_hugs@eml.cc changed:

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


--- Comment #1 from bearophile_hugs@eml.cc 2011-05-17 02:51:59 PDT ---
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: -------
June 12, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6000


kennytm@gmail.com changed:

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


--- Comment #2 from kennytm@gmail.com 2011-06-12 11:06:25 PDT ---
*** 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: -------