digitalmars.D.bugs - [Issue 15705] New: Invalid memory operation during array growth
- via Digitalmars-d-bugs (48/48) Feb 19 2016 https://issues.dlang.org/show_bug.cgi?id=15705
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 puremagic.com Reporter: matt.elkins 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 src\core\exception.d(679): Invalid memory operation This occurs during the failed assertion. --
Feb 19 2016