Bug 12685 – Refused foreach index type to span the whole range of the type

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2014-04-30T11:28:49Z
Last change time
2022-09-07T13:56:15Z
Keywords
diagnostic, rejects-valid
Assigned to
No Owner
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2014-04-30T11:28:49Z
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
Comment #1 by lio+bugzilla — 2014-06-30T03:32:23Z
*** Issue 12782 has been marked as a duplicate of this issue. ***
Comment #2 by nick — 2022-09-07T13:56:15Z
Works with dmd v2.100.2-beta.1-dirty.