[PATCH] D29908: Disallow returning a __block variable via a move
Akira Hatanaka via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 14 11:19:06 PST 2017
ahatanak added a comment.
In https://reviews.llvm.org/D29908#676589, @ahatanak wrote:
> Posting John's review comment, which was sent to the review I abandoned:
>
> "Hmm. The behavior I think we actually want here is that we should move out of the __block variable but not perform NRVO, essentially like we would if the variable were a parameter.
I think that's what's happening. Because of the changes made in r274291, NRVO isn't performed, but the move constructor instead of the copy constructor is called to return the shared_ptr. The shared_ptr in the heap is moved to returned shared_ptr (%agg.result), so when the block function passed to dispatch_async is executed, it segfaults because the object "ret" used to point to has been destructed.
If that's the case, should we conclude that clang is behaving as expected?
> The block byref copy helper should always be doing a move if it can, regardless of whether the function is returned. That's independent of this, though."
https://reviews.llvm.org/D29908
More information about the cfe-commits
mailing list