[Issue 22836] New: [Reg 2.070/2.093] foreach using ubyte index over static array of length 256 or ushort index over static array of length 65536 does not execute the foreach body

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Mar 2 15:55:48 UTC 2022


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

          Issue ID: 22836
           Summary: [Reg 2.070/2.093] foreach using ubyte index over
                    static array of length 256 or ushort index over static
                    array of length 65536 does not execute the foreach
                    body
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: n8sh.secondary at hotmail.com

Demonstration:

```
void main()
{
    ubyte[256] array;
    foreach (const ubyte i, ref a; array)
    {
        a = i;
    }
    assert(array[1] != 0); // Fails!
}
```

The above runs and the assertion passes in v2.069.2.

>From v2.070.2 through v2.092.1 the above fails to compile with the error
message "index type `const(ubyte)` cannot cover index range 0..256".

In v2.093.1 the above runs but the assertion fails.

--


More information about the Digitalmars-d-bugs mailing list