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

           Summary: Bad code with ref-foreach and closures
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: thecybersha...@gmail.com


--- Comment #0 from Vladimir Panteleev <thecybersha...@gmail.com> 2011-06-10 
02:18:34 PDT ---
void takeADelegate(void delegate()) {}

void main()
{
    auto items = new int[1];
    items[0] = 17;
    foreach (ref item; items)
    {
        // both asserts fail
        assert(item == 17);
        assert(&item == items.ptr);

        takeADelegate({
            auto x = &item;
        });
    }
}

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

Reply via email to