www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1815] New: foreach with interval does not increment pointers correctly

reply d-bugmail puremagic.com writes:
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 digitalmars.com
        ReportedBy: andrei 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.


-- 
Feb 04 2008
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1815


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #1 from bugzilla digitalmars.com  2008-02-28 22:43 -------
Fixed dmd 2.011


-- 
Feb 28 2008