[Issue 12685] New: Refused foreach index type to span the whole range of the type

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Apr 30 04:28:49 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=12685

          Issue ID: 12685
           Summary: Refused foreach index type to span the whole range of
                    the type
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Keywords: diagnostic, rejects-valid
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: bearophile_hugs at eml.cc

void main() {
    ubyte[2 ^^ 8] data1;
    foreach (ubyte i, x; data1) {}
    ushort[2 ^^ 16] data2;
    foreach (ushort i, x; data2) {}
}



DMD 2.066alpha gives false error messages:

temp.d(3,5): Error: index type 'ubyte' cannot cover index range 0..256
temp.d(5,5): Error: index type 'ushort' cannot cover index range 0..65536

--


More information about the Digitalmars-d-bugs mailing list