[Issue 4359] New: Erroneous behaviour of variables in a delegate literal passed as template tuple parameter

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 21 11:40:01 PDT 2010


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

           Summary: Erroneous behaviour of variables in a delegate literal
                    passed as template tuple parameter
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bugzilla at kyllingen.net


--- Comment #0 from Lars T. Kyllingstad <bugzilla at kyllingen.net> 2010-06-21 11:40:00 PDT ---
In the code below, the variable i is never increased above x+1.  It seems the
declaration inside the loop somehow overwrites i.  (Note that the writeln() is
only for demonstration purposes and has nothing to do with the bug.)


import std.stdio;

void run(fun...)()
{
    fun[0]();
}

void main()
{
    run!(delegate void()
    {
        for (int i = 0; i < 100_000; i++)
        {
            writeln(i);
            auto x = 0;  // i never exceeds 1
        }
    })();
}

-- 
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