[Issue 8774] 2.059 worked 2.060 does not: nested delegate memory corruption
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Dec 26 06:01:42 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8774
--- Comment #19 from Dmitry Olshansky <dmitry.olsh at gmail.com> 2012-12-26 06:01:41 PST ---
Reduced a tiny bit further and there 2 versions that work fine: OK and OK2.
Both are seemingly unrelated to the test.
void popFront(A)(ref A[] a)
{
a = a[1 .. $];
}
private struct MapResult(alias fun, Range)
{
alias Range R;
R _input;
this(R input)
{
_input = input;
}
@property bool empty()
{
return _input.length == 0;
}
void popFront()
{
version(OK)
_input = _input[1 .. $];
else
_input.popFront();
//
}
@property auto ref front()
{
return fun(_input[0]);
}
@property auto length()
{
return _input.length;
}
alias length opDollar;
}
int sliceBefore;
void corrupt( immutable int numberOfThreads ) {
immutable n = 1000000000 ;
immutable sliceSize = n / numberOfThreads ;
sliceBefore = sliceSize;
auto threads = MapResult!( ( int i ) {
auto closedPartialSum() {
version(OK2){} //omit ii and it works
else
{
immutable ii = i ;
}
return delegate ( ) {
assert(sliceSize == sliceBefore);
};
}
return closedPartialSum();
}, int[]) ( [0] );
//create array of delegates and copy them using range-based foreach
auto dgs = new void delegate()[threads.length];
size_t i=0;
foreach(dg; threads) //empty-front-popFront
dgs[i++] = dg;
foreach(dg; dgs)
dg();
}
void main(){
corrupt(1);
}
--
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