[Issue 2474] Recursive lazy arguments are inlined incorrectly
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Nov 27 08:51:09 PST 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2474
------- Comment #2 from snake.scaly at gmail.com 2008-11-27 10:51 -------
> I'm not sure if the compiler is actually within its rights to complain about
> this, as it's bad code even though not technically illegal...
>
> > Without the -inline flag this code compiles and works as expected.
>
> As in throws a stack overflow?
This is a reduced version of Knuth's "Man or Boy" test:
--8<----------------
import std.stdio;
int a(int k, lazy int x1, lazy int x2, lazy int x3, lazy int x4, lazy int x5)
{
int b()
{
k--;
return a(k, b(), x1, x2, x3, x4);
}
return k <= 0 ? x4 + x5 : b();
}
void main()
{
writefln(a(10, 1, -1, -1, 1, 0));
}
--8<----------------
>dmd manorboy.d
>manorboy
-67
>dmd -inline manorboy.d
manorboy.d(8): delegate manorboy.a.b.__dgliteral1 is a nested function and
cannot be accessed from a
manorboy.d(8): delegate manorboy.a.b.__dgliteral2 is a nested function and
cannot be accessed from a
manorboy.d(8): delegate manorboy.a.b.__dgliteral3 is a nested function and
cannot be accessed from a
manorboy.d(8): delegate manorboy.a.b.__dgliteral4 is a nested function and
cannot be accessed from a
manorboy.d(8): delegate manorboy.a.b.__dgliteral5 is a nested function and
cannot be accessed from a
See also the issue 2475, it's the same.
--
More information about the Digitalmars-d-bugs
mailing list