Skip to content

Conversation

@StephanTLavavej
Copy link
Member

Fixes #1102. This adds a few comments to the product code, explaining what's going on. Then, I enhanced our existing test for weak_ptr conversions to test owner_before and then use owner_before to test that control blocks are preserved. Finally, I added a small test for the behavior of virtual inheritance conversions before the object expired, since we weren't actually testing that.

Performance note: it would be possible to detect T* to const T* and avoid the _Incref_nz (which we did before this PR too, in the form of _Other.lock()); I could file an issue about that after merging this PR if anyone is interested. At this time, we don't know if it's possible to detect virtual base traversal in general, without a compiler builtin.

@StephanTLavavej StephanTLavavej added bug Something isn't working high priority Important! labels Jul 29, 2020
@StephanTLavavej StephanTLavavej requested a review from a team as a code owner July 29, 2020 06:43
@StephanTLavavej StephanTLavavej merged commit 57db210 into microsoft:master Aug 1, 2020
@StephanTLavavej StephanTLavavej deleted the weak_ptr branch August 1, 2020 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working high priority Important!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

<memory>: weak_ptr conversions don't preserve control blocks for expired objects

3 participants