Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Fixes bug 5272 -- Postblit not called on copying due to array append #29

Merged
merged 2 commits into from
Jun 21, 2011

Conversation

schveiguy
Copy link
Member

Added handling of postblit to all array operations.

Passes all druntime and phobos unit tests on Linux.

postblit now called in all cases where lifetime.d copies data.
@michelf
Copy link
Contributor

michelf commented Jun 17, 2011

Is this the right place to fix it though? Postblit should only happen when copying and not when moving. If you do something like this:

 S[] a;
 a ~= S();

I wouldn't expect postblit to be called at all, since you're simply moving the new S to the end of the array. Is this handled correctly by this patch?

@schveiguy
Copy link
Member Author

michelf, it is impossible for the runtime to tell whether this is a move or a copy.

For example, the above code could be written:

 S s;
 a ~= s;

And the same exact runtime function is called with the same exact argument types. In order to fix this, the compiler would have to be modified (maybe a bool identifying move/copy?)

But I do agree it is an issue, could you file a separate bug report?

@michelf
Copy link
Contributor

michelf commented Jun 18, 2011

I'm not sure how I should fill a bug for something that isn't a bug yet. Moving a struct by appending it to an array works as expected currently (no postblit). The behaviour will become wrong only once this request is pulled.

@schveiguy
Copy link
Member Author

Well, it's only not a bug because postblit is not implemented at all. The bug is that the compiler doesn't give the runtime enough info to make the right decision. The patch fixes all cases where postblit should be called. I can file the bug if you like.

On Jun 18, 2011, at 9:59 AM, michelf reply@reply.github.com wrote:

I'm not sure how I should fill a bug for something that isn't a bug yet. Moving a struct by appending it to an array works as expected currently (no postblit). The behaviour will become wrong only once this request is pulled.

Reply to this email directly or view it on GitHub:
#29 (comment)

schveiguy added a commit that referenced this pull request Jun 21, 2011
Fixes bug 5272 -- Postblit not called on copying due to array append
This does not fix all slice operation postblit semantics.  More patches forthcoming.
@schveiguy schveiguy merged commit 97d6b19 into dlang:master Jun 21, 2011
@schveiguy schveiguy deleted the bug5272 branch February 10, 2015 17:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants