www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21067] New: Tupleof of struct returned by function with

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

          Issue ID: 21067
           Summary: Tupleof of struct returned by function with string
                    field lazily passed to function, itself lazily passed
                    to another function, causes runtime OOM.
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: default_357-line yahoo.de

Consider the following, remarkable code:

struct S { int b; string s; }

S test() { return S(); }

void main()
{
    evalArg(dupArg2(test.tupleof));
}

void dupArg2(int, lazy string msg)
{
    msg().dup;
}

void evalArg(lazy void expression)
{
    try expression();
    finally { }
}

When built and run with DMD, I get an OOM error.

LDC gives the somewhat more helpful error:

test.d(7): Error: function test.main.__dgliteral1 cannot access frame of
function test.main.__dgliteral2

For the evalArg call. Indicating the issue is related to the double-nesting of
lazy.

--
Jul 23 2020