[Issue 5690] New: Struct const member makes struct const

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 3 05:37:20 PST 2011


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

           Summary: Struct const member makes struct const
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: tarossi at gmail.com


--- Comment #0 from Tom <tarossi at gmail.com> 2011-03-03 05:34:25 PST ---
int main(string[] args) {
    auto s1 = f(); // MH MH
    auto s2 = g(); // OK
    s2.c = null; // OK
    return 0;
}

class C {}

struct StructWithConstMember {
    this(int i, C c) { this.i=i; this.c=c; }
    int i;
    const(C) c;
}

struct StructWithoutConstMember {
    this(int i, C c) { this.i=i; this.c=c; }
    int i;
    C c;
}

ref StructWithConstMember f() {
    return * new StructWithConstMember(1, new C); // ERROR
}

ref StructWithoutConstMember g() {
    return * new StructWithoutConstMember(1, new C); // OK
}


src\main.d(27): Error: *new StructWithConstMember(1,new C) is not mutable

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


More information about the Digitalmars-d-bugs mailing list