[Issue 15705] New: Invalid memory operation during array growth (@safe code)
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Feb 19 06:11:35 PST 2016
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: nobody at puremagic.com
Reporter: matt.elkins at gmail.com
See this forum discussion for more context:
https://forum.dlang.org/post/jqivvwxqetxqajukcxks@forum.dlang.org
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 at src\core\exception.d(679): Invalid
memory operation
This occurs during the failed assertion.
--
More information about the Digitalmars-d-bugs
mailing list