D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4359 - Erroneous behaviour of variables in a delegate literal passed as template tuple parameter
Summary: Erroneous behaviour of variables in a delegate literal passed as template tup...
Status: RESOLVED DUPLICATE of issue 1350
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other All
: P2 normal
Assignee: No Owner
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2010-06-21 11:40 UTC by Lars T. Kyllingstad
Modified: 2010-07-16 10:20 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Lars T. Kyllingstad 2010-06-21 11:40:00 UTC
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
        }
    })();
}
Comment 1 Don 2010-07-16 10:14:06 UTC

*** This issue has been marked as a duplicate of issue 4246 ***
Comment 2 Don 2010-07-16 10:20:02 UTC
Actually bug 4246 is itself a duplicate of 1350.

*** This issue has been marked as a duplicate of issue 1350 ***