[Issue 2475] New: -inline breaks man or boy

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 27 00:16:40 PST 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2475

           Summary: -inline breaks man or boy
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: bugzilla at digitalmars.com


Wed, 26 Nov 2008 17:02:54 -0500, bearophile wrote:

> > While on DMD 1.036 the following code:
> > 
> > // code #2
> > import std.c.stdio: printf;
> > 
> > int a(int k, lazy int x1, lazy int x2, lazy int x3, lazy int x4, lazy int x5) {
> >     int b() {
> >         k -= 1;
> >         return a(k, b(), x1, x2, x3, x4);
> >     }
> >     return k <= 0 ? x4 + x5 : b();
> > }
> > 
> > void main() {
> >     printf("%d\n", a(24, 1, -1, -1, 1, 0));
> > }
> > 
> > Outputs at compile time:
> > 
> > man_or_boy2.d(6): delegate man_or_boy2.a.b.__dgliteral1 is a nested function and cannot be accessed from a
> > man_or_boy2.d(6): delegate man_or_boy2.a.b.__dgliteral2 is a nested function and cannot be accessed from a
> > man_or_boy2.d(6): delegate man_or_boy2.a.b.__dgliteral3 is a nested function and cannot be accessed from a
> > man_or_boy2.d(6): delegate man_or_boy2.a.b.__dgliteral4 is a nested function and cannot be accessed from a
> > man_or_boy2.d(6): delegate man_or_boy2.a.b.__dgliteral5 is a nested function and cannot be accessed from a
> > 
> > But this code works on the codepad site, that uses DMD v.1.026 (I think with Tangobos), up to N=21 (then the site goes into timeout for safety):
> > http://codepad.org/8GtKswm8

[snip]

> > All the following compilations are done with and N=20 and:
> > dmd -O -release -inline -L/STACK:1700000000 man_or_boy.d
> > dmd -O -release -inline -L/STACK:1700000000 man_or_boy2.d

Remove -inline from your compiler options, and #2 compiles and runs
faster in both D1 and D2 than #1.

lazy seems to do something funny when -inline is in effect.


-- 



More information about the Digitalmars-d-bugs mailing list