D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6182 - _d_arraycopy should take TypeInfo as final argument instead of simply element size
Summary: _d_arraycopy should take TypeInfo as final argument instead of simply element...
Status: RESOLVED DUPLICATE of issue 6470
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 major
Assignee: No Owner
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2011-06-20 08:19 UTC by Steven Schveighoffer
Modified: 2013-06-13 07:29 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Steven Schveighoffer 2011-06-20 08:19:39 UTC
This allows implementation of postblit (and possibly other runtime tasks) when array copying is done.

For example, a[] = b[] will not call any postblits on the data copied.

Once the compiler is fixed, I can generate a pull request to fix the runtime.
Comment 1 timon.gehr 2012-02-10 12:09:34 UTC
This is not an enhancement. postblits not being called is a clear bug.
Comment 2 Kenji Hara 2013-06-13 03:38:24 UTC
I checked this with 2.064a(fbd6c9f)

struct S
{
    static int cnt;
    this(this) { ++cnt; }
}
void main()
{
    S[3] sa1;
    S[3] sa2;
    sa1[] = sa2[];
    printf("S.cnt = %d\n", S.cnt);     // prints 3

    auto da1 = new S[](3);
    auto da2 = new S[](3);
    da1[] = da2[];
    printf("S.cnt = %d  \n", S.cnt);   // prints 6
}

Is this already fixed?
Comment 3 Peter Alexander 2013-06-13 03:56:44 UTC
(In reply to comment #2)
> Is this already fixed?

It appears to have been fixed in 2.060 by yourself.

It was fixed against Issue 6470.
Comment 4 Benjamin Thaut 2013-06-13 06:55:06 UTC
(In reply to comment #2)
> 
> Is this already fixed?

I just debugged it with dmd 2.063 where it is already fixed. It seems that the compiler now generates a call to _d_arrayassign as soon as the array is made of structs that have a postblit constructor or destructor. I didn't know _d_arrayassign did exist, so this bug is both fixed and invalid. _d_arraycopy was never intended to be used for complex types. _d_arrayassign exists for this purpose as far as I understand it.
Comment 5 Steven Schveighoffer 2013-06-13 07:29:05 UTC
This was a LOOONG time ago :)  Certainly possible it was fixed, and in a different way than I asked for.  I'll close it, it seems issue 6470 was a better solution.

*** This issue has been marked as a duplicate of issue 6470 ***