www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6759] New: missing initialization in foreach with alias this

reply d-bugmail puremagic.com writes:
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: nobody puremagic.com
        ReportedBy: dawg dawgfoto.de



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


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 02 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6759




Your patch was already merged (commit: f53ff46), and it looks correct to me the
fixing lack of merging prelude before semantic.

But, your sample code works before merging (commit: 07f719e), so that code is
not test case of this issue.

Do you have right test case?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 02 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6759


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED



12:54:32 PDT ---
https://github.com/D-Programming-Language/dmd/commit/fed2faabc3ca9f67a429293eee82ae597061fea8

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 02 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6759





 Your patch was already merged (commit: f53ff46), and it looks correct to me the
 fixing lack of merging prelude before semantic.
 
 But, your sample code works before merging (commit: 07f719e), so that code is
 not test case of this issue.
 
 Do you have right test case?
This is probably due to constant folding or optimization. The merged version has 'assert(e == 0);' in the loop body. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 05 2011