[Issue 1815] New: foreach with interval does not increment pointers correctly
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Feb 4 21:06:08 PST 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1815
Summary: foreach with interval does not increment pointers
correctly
Product: D
Version: unspecified
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: andrei at metalanguage.com
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.
--
More information about the Digitalmars-d-bugs
mailing list