[Issue 8931] array/slice assignment causes destruction + postblit instead of opAssign

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Sep 5 00:36:59 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=8931



--- Comment #4 from monarchdodra at gmail.com 2013-09-05 00:36:55 PDT ---
(In reply to comment #3)
> (In reply to comment #2)
> > I mean:
> > //----void main()
> > {
> >     S[2] a = [S(1), S(2)];
> >     S[2] b = a; //Fine postblit here
> >     a[] = b[];  //But HERE, please use opAssign.
> > }
> > //----
> 
> I see now and it does make sense. But it seems to be impossible now because of
> how _d_arrayassign function
> (https://github.com/D-Programming-Language/druntime/blob/master/src/rt/arrayassign.d#L30)
> assigns arrays: it uses memcpy+postblit+destroy because TypeInfo class
> (https://github.com/D-Programming-Language/druntime/blob/master/src/object.di#L68)
> lacks entry related to opAssign method.

I did some extra thinking about this, and this might be invalid. While one
might "expect" opAssign to be called, doing this would mean it is impossible to
have a strong exception safe behavior should one of the assignements fails.

Using postblit does (can[1]) guarantee that.

[1]: See also http://d.puremagic.com/issues/show_bug.cgi?id=10967

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


More information about the Digitalmars-d-bugs mailing list