January 20, 2015 Memory error when using a template in a class destructor | ||||
|---|---|---|---|---|
| ||||
The following code throws a core.exception.InvalidMemoryOperationError@(0), anyone have an idea of what is causing it? --- import std.stdio; class Test { this() { struct Start { string filename; } Message!(Start)(Start("one.txt")); } ~this() { struct Stop { string filename; } Message!(Stop)(Stop("one.txt")); } } unittest { auto t = new Test(); } struct Message(T) { this(T message) { writeln(typeid(T)); writeln(message); } | ||||
January 20, 2015 Re: Memory error when using a template in a class destructor | ||||
|---|---|---|---|---|
| ||||
Posted in reply to JC Attachments: | On Tue, 20 Jan 2015 17:59:38 +0000 JC via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote: > The following code throws a core.exception.InvalidMemoryOperationError@(0), anyone have an idea of what is causing it? > > --- > > import std.stdio; > > class Test > { > this() > { > struct Start > { > string filename; > } > Message!(Start)(Start("one.txt")); > } > > ~this() > { > struct Stop > { > string filename; > } > Message!(Stop)(Stop("one.txt")); > } > } > > unittest > { > auto t = new Test(); > } > > struct Message(T) > { > this(T message) > { > writeln(typeid(T)); > writeln(message); > } `writeln` can allocate. | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply