https://issues.dlang.org/show_bug.cgi?id=15705
Issue ID: 15705
Summary: Invalid memory operation during array growth (@safe
code)
Product: D
Version: D2
Hardware: x86_64
URL: http://dlang.org/phobos/
OS: Windows
Status: NEW
Severity: normal
Priority: P3
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
See this forum discussion for more context:
https://forum.dlang.org/post/[email protected]
Consider the following code:
[code]
import std.stdio;
@safe:
bool scopeEnded;
struct Foo
{
@disable this(this);
this(int val) {writeln("Constructing: ", val, " (", &this, ")"); value =
val;}
~this() {writeln("Destroying: ", value, " (", &this, ")"); assert(value ==
int.init || scopeEnded);}
int value;
}
unittest
{
Foo[] foos;
for (auto i = 0; i < 10000; ++i)
{
++foos.length;
foos[$ - 1] = Foo(i);
}
writeln("Scope about to end");
scopeEnded = true;
}
[/code]
This yields (among other output):
core.exception.InvalidMemoryOperationError@src\core\exception.d(679): Invalid
memory operation
This occurs during the failed assertion.
--