digitalmars.D.bugs - [Issue 5958] New: const/immutable ignored passing to opAssign()
- d-bugmail puremagic.com (39/39) May 08 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5958
- d-bugmail puremagic.com (13/13) May 10 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5958
http://d.puremagic.com/issues/show_bug.cgi?id=5958 Summary: const/immutable ignored passing to opAssign() Product: D Version: D2 Platform: x86_64 OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: marcianx gmail.com --- Comment #0 from marcianx gmail.com 2011-05-08 11:23:17 PDT --- I saw examples in the D Programming Language book (Page 256) where opAssign() took a ref argument instead of a const ref. Just to test, I made example below which incorrectly compiles and runs with both gdc and dmd for D2. The example also works with immutable replaced by const. import std.stdio; struct Foo { auto ref opAssign(ref Foo s) { s.x = 4; // modifying mutable object !!! x = s.x; return this; } private int x = 0; } void main(string[] args) { immutable(Foo) foo = Foo(); auto foo2 = Foo(); writefln("(immutable!) foo.x = %s", foo.x); // prints 0 foo2 = foo; // allowed immutable RHS ??? writefln("(immutable?) foo.x = %s", foo.x); // prints 4 } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 08 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5958 Stewart Gordon <smjg iname.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |accepts-invalid Status|NEW |RESOLVED CC| |smjg iname.com Resolution| |DUPLICATE --- Comment #1 from Stewart Gordon <smjg iname.com> 2011-05-10 16:55:57 PDT --- *** This issue has been marked as a duplicate of issue 5493 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 10 2011