View mode: basic / threaded / horizontal-split · Log in · Help
February 22, 2013
[Issue 9572] New: Missed wrong implicit integral conversion
http://d.puremagic.com/issues/show_bug.cgi?id=9572

          Summary: Missed wrong implicit integral conversion
          Product: D
          Version: D2
         Platform: All
       OS/Version: All
           Status: NEW
         Keywords: accepts-invalid, diagnostic
         Severity: normal
         Priority: P2
        Component: DMD
       AssignedTo: nobody@puremagic.com
       ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2013-02-22 11:09:10 PST ---
void main() {
   int[300] data;
   foreach (ubyte i, x; data) {} // Line 3, no error.
   ubyte j = data.length; // Line 4, Error.
}


DMD 2.063alpha gives:

temp.d(4): Error: cannot implicitly convert expression (300u) of type uint to
ubyte


But line 3 should give a similar error message, because data has 300 items, so
the "i" index can't represent all the possible indexes.

See also issue 9570.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Top | Discussion index | About this forum | D home