[Issue 6111] Escaping reference to local variable not detected

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 6 16:02:19 PDT 2011


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



--- Comment #1 from Walter Bright <bugzilla at digitalmars.com> 2011-06-06 15:57:49 PDT ---
Reduced test case:

import std.c.stdio;

auto mymap()
{
    int x = 42;
    int fun(int a) { return x + a; }

    auto map()(int r)
    {
        struct Result
        {
            int _input;

            int back()
        {
        return fun(_input);
        }

            this(int input)
            {
                _input = input;
            }
        }

        return Result(r);
    }

    return map(1);
} 

void main()
{
    printf("%d\n", mymap().back());
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list