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


--- Comment #0 from Andrei Alexandrescu <andrei metalanguage.com> 2012-12-13
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



--- Comment #1 from Andrei Alexandrescu <andrei metalanguage.com> 2012-12-13
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



--- Comment #2 from Kenji Hara <k.hara.pg gmail.com> 2012-12-13 21:02:05 PST ---
(In reply to comment #1)
 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 (mainly dmd pull #166). - 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


--- Comment #3 from Kenji Hara <k.hara.pg gmail.com> 2012-12-13 21:04:27 PST ---
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


--- Comment #4 from Kenji Hara <k.hara.pg gmail.com> 2012-12-26 06:48:07 PST ---
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



--- Comment #5 from github-bugzilla puremagic.com 2012-12-26 14:23:26 PST ---
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
Merge pull request #1375 from 9rnsr/fix9154

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