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

           Summary: missing initialization in foreach with alias this
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: d...@dawgfoto.de


--- Comment #0 from d...@dawgfoto.de 2011-10-02 05:03:02 PDT ---
struct Range
{
    size_t front() { return 0; }
    void popFront() { empty = true; }
    bool empty;
}

struct ARange
{
    Range range;
    alias range this;
}

void main()
{
    ARange arange;
    assert(arange.front == 0);
    foreach(e; arange)
    {}
}

---

Foreach creates a reference to arange.
The expression that initializes the reference is dropped
for alias this aggregates.

This is a regression introduced by
https://github.com/D-Programming-Language/dmd/commit/6a2aefdb468d20aa8d498c8930c2613d78a91238
as a fix to #2781.

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

Reply via email to