www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10079] New: Builit-in generated opAssign should be pure nothrow safe in default

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

           Summary: Builit-in generated opAssign should be pure nothrow
                     safe in default
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: k.hara.pg gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg gmail.com> 2013-05-13 20:49:44 PDT ---
If a struct has postblit or destructor, assignment is automatically implemented
with swap-and -destroy..

struct S {
    this(this) {}   // or ~this()
}
void main() {
    S s1, s2;
    s1 = s2;   // is equivalent to
    // auto tmp = s2   // bitwise copy
    // swap(s1, tmp);  // bitwise swap
    // destroy tmp;    // destroy old state of s1
}

The bitwise copy and swap are pure, nothrow and  safe. But currently this code
doesn't work.

struct S {
    this(this) pure nothrow  safe {}
    // and/or ~this() pure nothrow  safe {}
}
void main() pure nothrow  safe {
    S s1, s2;
    s1 = s2;
}

test.d(7): Error: pure function 'D main' cannot call impure function
'test.S.opAssign'
test.d(7): Error: safe function 'D main' cannot call system function
'test.S.opAssign'
test.d(7): Error: s1.opAssign is not nothrow
test.d(5): Error: function D main 'main' is nothrow yet may throw

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


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc
            Summary|Builit-in generated         |Builit-in generated
                   |opAssign should be pure     |opAssign should be pure
                   |nothrow  safe in default    |nothrow  safe on default


--- Comment #1 from bearophile_hugs eml.cc 2013-05-14 02:36:47 PDT ---
Changed issue name a little.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 14 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10079


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #2 from Kenji Hara <k.hara.pg gmail.com> 2013-05-14 20:18:51 PDT ---
https://github.com/D-Programming-Language/dmd/pull/2036

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 14 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10079


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Builit-in generated         |Built-in generated opAssign
                   |opAssign should be pure     |should be pure nothrow
                   |nothrow  safe on default    | safe by default


--- Comment #3 from Don <clugdbug yahoo.com.au> 2013-05-15 03:59:13 PDT ---
 Changed issue name a little.
:) Your name change was exactly as grammatically incorrect as the original! -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 15 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10079



--- Comment #4 from github-bugzilla puremagic.com 2013-06-25 14:39:43 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/8231f4c9247aefa32e55a1e61f7533079cd147a1
fix Issue 10079 - Builit-in generated opAssign should be pure nothrow  safe on
default

https://github.com/D-Programming-Language/dmd/commit/9fad79d33406c82cbdec62ac3e6e5ad2e29db4e4
Merge pull request #2036 from 9rnsr/fix10079

Issue 10079 - Builit-in generated opAssign should be pure nothrow  safe on
default

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 25 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10079


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: -------
Jun 25 2013