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

           Summary: Nested struct `init` is lvalue and can be modified
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: wrong-code
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: [email protected]
        ReportedBy: [email protected]


--- Comment #0 from Denis Shelomovskij <[email protected]> 2012-11-16 
15:56:27 MSK ---
---
struct S { }

void f(T)(auto ref T t)
{ static assert(!__traits(isRef, t)); }

void main()
{
    f(S.init); // ok, rvalue
    f(S());    // ok, rvalue

    int i;
    struct Nested
    { int j = 0; void f() { ++i; } }
    f(Nested()); // ok, rvalue
    f(Nested.init); // fails, lvalue

    assert(Nested.init.j == 0);
    (ref n) { n.j = 5; }(Nested.init);
    assert(Nested.init.j == 0); // fails, j is 5
}
---

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

Reply via email to