www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9154] New: Incorrectly generated assignment operator

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9154

           Summary: Incorrectly generated assignment operator
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: andrei metalanguage.com



19:53:51 PST ---


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 13 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9154




19:57:18 PST ---
Consider:

    struct S {
      int x;
      void opAssign(ref S s) { }
    }

    struct T {
      S member;
     }

    void main() {
      T t1, t2;
      t1 = t2;
    }

This fails to compile with the error:

    Error: cannot modify struct t1 T with immutable members 

The error is caused by the "ref" in the definition of opAssign. Replacing "ref"
with "ref const" or "ref immutable" doesn't help, either.

The compiler should act mechanically here: the generated assignment for T
should simply perform a field-by-field assignment without nitpicking.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 13 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9154





 The compiler should act mechanically here: the generated assignment for T
 should simply perform a field-by-field assignment without nitpicking.
OK. When I organized "identity assignable" concept, I had lacked it in my fix - Even if user defines an opAssign which receives only lvalue, compiler should treat it as identity opAssign. This is satisfied the condition for field-by-field assignment. Then, S is treated as an "identity assignable" struct, and built-in opAssign generating in T will succeed correctly. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 13 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9154


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid



https://github.com/D-Programming-Language/dmd/pull/1375

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 13 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9154


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |regression



This is a regression caused by fixing bug 4424 in 2.061head.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 26 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9154




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/fefb45212291c7fbe72cb30501a3edb4caf047e2
fix Issue 9154 - Incorrectly generated assignment operator

https://github.com/D-Programming-Language/dmd/commit/6c7fa392f60af6319a5979b98d42c89f0b1adde4


Issue 9154 - Incorrectly generated assignment operator

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 26 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9154


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


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