[Issue 15409] New: Mallocator cant be used in @nogc code

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Dec 5 10:59:23 PST 2015


https://issues.dlang.org/show_bug.cgi?id=15409

          Issue ID: 15409
           Summary: Mallocator cant be used in @nogc code
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: bb.temp at gmx.com

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- at nogc function 'std.experimental.allocator.mallocator.Mallocator.allocate'
 

--


More information about the Digitalmars-d-bugs mailing list