Bug 15409 – Mallocator cant be used in @nogc code

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-12-05T18:59:00Z
Last change time
2016-01-03T14:15:10Z
Assigned to
nobody
Creator
b2.temp

Comments

Comment #0 by b2.temp — 2015-12-05T18:59:23Z
Despite of the fact that std.experimental.allocator.mallocator allocators (aligned and malloc) don't allocate on the gc-heap, they can't be used in @nogc functions. for example: ~~~~~~~~~~~~~~~~~ auto myAlloc(size_t size) @nogc { import std.experimental.allocator.mallocator; return Mallocator.instance.allocate(size); } void main(string[] args) { myAlloc(10); } ~~~~~~~~~~~~~~~~~ > /tmp/temp_7FFA2DEB9BF0.d(8,40): Error: @nogc function 'runnable.myAlloc' cannot call non-@nogc function 'std.experimental.allocator.mallocator.Mallocator.allocate'
Comment #1 by github-bugzilla — 2015-12-07T05:51:45Z
Commit pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/61b07a39b129cb2a0d712c3216868482ee80725a Merge pull request #3856 from BBasile/mallocator-nogc fix issue 15409 - Mallocator cant be used in @nogc code
Comment #2 by github-bugzilla — 2016-01-03T14:15:10Z