Bug 1815 – foreach with interval does not increment pointers correctly
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2008-02-04T23:06:00Z
Last change time
2015-06-09T05:15:13Z
Assigned to
bugzilla
Creator
andrei
Comments
Comment #0 by andrei — 2008-02-04T23:06:07Z
The following code asserts and it shouldn't:
void main()
{
int[] array = new int[5];
uint check = 0;
foreach (it; array.ptr .. array.ptr + array.length) {
++check;
}
assert(check == array.length);
}
What happens (easily observable by printing it) is that the pointer gets incremented by 1, not by int.sizeof.