www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8974] New: closure delegate might break preceding code

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8974

           Summary: closure delegate might break preceding code
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: fawzi gmx.ch



I found the particularly nasty example where introducing a non scoped delegate
breaks the preceding loop with DMD 2.060.

-------------
module t6;
import core.stdc.stdio;

void ff(T)(T[] arr1){
    T[] copyArr=new T[](arr1.length);
    size_t ii=0;

    foreach(size_t i,T e;arr1){
        // i is invalid, accessing did segfaults in the original bug
        // changing the delegate below (to remove code dep) it is now "only"
invalid
        printf("i=%ld\n",i);
        scope dl=delegate void(int sink){
            if (i>10)
                assert(0);
        };
    }
    ii=0;
    // using a scoped delegate here removes the bug
    auto dlg=delegate bool(ref T*el){
        if (ii<1){ // originally also ++ii;
            return true;
        }
        return false;
    };
}

int main(string[]args){
    int[]narr=new int[](3);
    ff(narr);
    return 0;
}
----------

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 07 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8974


Kenji Hara <k.hara.pg gmail.com> changed:

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



*** This issue has been marked as a duplicate of issue 8526 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 08 2012