Bug 16064 – std.experimental.allocator.dispose can't be used in @nogc blocks

Status
RESOLVED
Resolution
DUPLICATE
Severity
major
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-05-23T14:49:34Z
Last change time
2017-10-03T13:39:02Z
Assigned to
Eduard Staniloiu
Creator
Basile B.

Comments

Comment #0 by b2.temp — 2016-05-23T14:49:34Z
There's a flaw, the following code doesn't compile, even if Mallocator is 100% @nogc and that the __dtor is @nogc ---- import std.experimental.allocator; import std.experimental.allocator.mallocator; class Foo { ~this()@nogc {} } void main() @nogc { Foo foo = make!Foo(Mallocator.instance); dispose(Mallocator.instance, foo); } ---- The problem is due to dispose() that calls destroy() which is not a template and thus cannot infer the attributes. A possible fix is to write a custom destroy() that would call __dtor or __xdtor, at least for classes and pointer to structs, as a template, and used in dispose().
Comment #1 by simen.kjaras — 2017-10-03T13:39:02Z
This is the same bug as 15246, 17297 and 17592, just in a different guise. *** This issue has been marked as a duplicate of issue 17592 ***