[Issue 14126] GITHEAD - GC seemingly corrupting memory
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Feb 4 19:46:02 PST 2015
https://issues.dlang.org/show_bug.cgi?id=14126
Orvid King <blah38621 at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |blah38621 at gmail.com
--- Comment #1 from Orvid King <blah38621 at gmail.com> ---
The invalid memory operation exception is expected, as you are trying to do an
allocation in a destructor.
As a note, it doesn't appear that the issue is with the main class, as this
still produces the same error:
import std.stdio;
import std.conv;
class FooBar
{
Foo[] _foos;
this()
{
_foos = new Foo[512];
foreach (i; 0.._foos.length)
_foos[i] = Foo(1);
}
}
struct Foo
{
uint _foo = 0;
this(uint foo)
{
writeln("Foo init");
assert(foo == 1);
_foo = foo;
}
~this()
{
if (_foo != 0 && _foo != 1)
{
writeln("How can _foo have any other value than 0 or 1?");
writeln(_foo, "?? really????");
assert(false, "Unexpected Value: " ~ _foo.to!string());
}
}
}
void main()
{
auto bar = new FooBar();
writeln("End of main");
}
--
More information about the Digitalmars-d-bugs
mailing list