[Issue 8974] New: closure delegate might break preceding code
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Nov 7 14:52:44 PST 2012
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 at puremagic.com
ReportedBy: fawzi at gmx.ch
--- Comment #0 from Fawzi Mohamed <fawzi at gmx.ch> 2012-11-07 14:52:41 PST ---
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: -------
More information about the Digitalmars-d-bugs
mailing list