[Issue 14982] New: nogc inconsistency

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Aug 30 05:01:44 PDT 2015


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

          Issue ID: 14982
           Summary: nogc inconsistency
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: john.loughran.colvin at gmail.com

import std.algorithm, std.range;

auto foo(int[] a, immutable int b) @nogc //Fails
{
    return a.map!(x => x + b);
}

auto bar(R)(R a, immutable int b) @nogc //OK
{
    return a.map!(x => x + b);
}

auto baz(int[] a, immutable int b) @nogc //OK
{
    return bar(a, b);
}

Foo cannot be made @nogc:
Error: function nogctest.foo @nogc function allocates a closure with the GC

--


More information about the Digitalmars-d-bugs mailing list