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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 1 11:07:10 PDT 2012


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



--- Comment #2 from monarchdodra at gmail.com 2012-11-01 11:07:07 PDT ---
(In reply to comment #1)
> I don't understand clearly this issue. You first state that when arrays are
> assigned you expect that this is done element-by element, but actually all
> elements of an array are firstly destroyed and then replaced.
> 
> However output shows just the opposite: assignment is done element-by-element.
> Differences between two versions of main() are in the fact that elements of
> fixed arrays are constructed (because fixed arrays are of value semantic) and
> in order of assignment: in fixed array case elements are copied from the
> beginning and in case of dynamic arrays the operation starts from the last
> element. None of versions calls opAssign. I don't understand how your
> conclusion is based on code and what you are trying to say.

I'm sorry I did not make myself clear. The issue was not about the order (I
hadn't even noticed the difference between both version).

The issue is that the elements in the destination array (a) are destroyed and
then postblit recreated.

I'd have expected to see assignments instead.

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.
}
//----

-- 
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