www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12486] New: Function returning struct isn't called if `enum` of its result is accessed

https://d.puremagic.com/issues/show_bug.cgi?id=12486

           Summary: Function returning struct isn't called if `enum` of
                    its result is accessed
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: wrong-code
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: verylonglogin.reg gmail.com


--- Comment #0 from Denis Shelomovskij <verylonglogin.reg gmail.com> 2014-03-28
16:39:45 MSK ---
This code should run fine:
---
struct S { enum a = 1; } // or `const` but not for all types

S f(ref int i)
{
    ++i;
    return S();
}

void main()
{
    int i = 2;
    assert(f(i).a == 1);
    assert(i == 3); // fails, i = 2
}
---

This affects infinite ranges processing e.g. `canFind(repeat(1), 2)` always
returns `true` instead of infinite looping.

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