digitalmars.D.bugs - [Issue 8955] New: Can't have qualified field with not-qualified constructor/postblit
- d-bugmail puremagic.com (56/56) Nov 03 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8955
- d-bugmail puremagic.com (32/32) Nov 03 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8955
- d-bugmail puremagic.com (12/12) Jan 09 2013 http://d.puremagic.com/issues/show_bug.cgi?id=8955
http://d.puremagic.com/issues/show_bug.cgi?id=8955 Summary: Can't have qualified field with not-qualified constructor/postblit Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: rejects-valid Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: verylonglogin.reg gmail.com 15:55:14 MSK --- Currently constructor/postblit isn't qualified (see Issue 4338 and Issue 4867). But it's violated for struct members: --- struct S { this(this) { } ~this() { } } struct S2 { S s; } const S globalS; // ok const S2 globalS2; // ok void f() { const S localS; // ok const S2 localS2; // ok } struct S3 // or class, or union { const S s; } // any qualifier causes errors --- Errors for S with postblit only: --- Error: function main.S.__postblit () is not callable using argument types () const --- Errors for S with destructor ony (note generated `opAssign`): --- Error: destructor main.S.~this () is not callable using argument types () const Error: function main.S.opAssign (S p) is not callable using argument types (const(S)) const --- Errors for S with postblit and destructor: --- Error: destructor main.S.~this () is not callable using argument types () const Error: function main.S.__postblit () is not callable using argument types () const --- There is no line numbers in errors because of Issue 8954. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 03 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8955 17:25:18 MSK --- Partial workaround: For const/immutable postblit/dtor: --- struct S { private void myPostblit() { } this(this) inout { (cast(S*) &this).myPostblit(); } private void myDtor() { } ~this() inout // Plese `inout` before `~this()` if Issue 8953 unfixed { (cast(S*) &this).myDtor(); } } struct S_ { const S sc; immutable S si; } --- Note: at least `this(this) inout { }` or `opAssign` is required for dtor For shared dtor: --- struct S { void opAssign(shared S s) shared { this = s; } // required for dtor private void myDtor() { } shared~this() // Plese `inout` before `~this()` if Issue 8953 unfixed { (cast(S*) &this).myDtor(); } } struct S_ { shared S sc; } --- Same for constructor except it doesn't require somebody like dtor. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 03 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8955 jens.k.mueller gmx.de changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jens.k.mueller gmx.de I stumbled over this today. What I don't understand is why/how postblit can be const? I mean if the object is const then I shouldn't be allowed to change it. Because you are copying to something that is const. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 09 2013