[Issue 15809] Putting std.stdio.File.ByLine in a class causes Invalid memory operation upon exit
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Mar 22 10:35:11 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=15809
--- Comment #2 from ag0aep6g at gmail.com ---
It boils down to this:
----
alias T = void*;
struct RefCounted
{
T* _store;
this(int dummy)
{
import core.memory : GC;
import core.stdc.stdlib : malloc;
_store = cast(T*)malloc(T.sizeof);
GC.addRange(&_store, T.sizeof);
}
~this()
{
assert(_store !is null);
import core.memory : GC;
GC.removeRange(&_store);
}
}
void main()
{
auto a = new RefCounted(0);
}
----
I don't know if there's anything wrong with this usage of
GC.addRange/GC.removeRange. If there is, this is a bug in
std.typecons.RefCounted. If there's not, it's a druntime/dmd issue.
--
More information about the Digitalmars-d-bugs
mailing list