-
Notifications
You must be signed in to change notification settings - Fork 511
[API] fix shared_ptr self assignments #3768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Should I remove the unit test not belonging to this PR? It increases test coverage but I'm not sure whether you want to see it in a different commit! |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3768 +/- ##
==========================================
- Coverage 89.95% 89.93% -0.01%
==========================================
Files 225 225
Lines 7158 7165 +7
==========================================
+ Hits 6438 6443 +5
- Misses 720 722 +2
🚀 New features to boost your workflow:
|
Please keep the test, this is fine. It needs to build in CI, there is a self move warning. Maybe use another variable, like: |
Or if we need to test self-assignment for shared pointer. ptr1 = ptr1; |
lalitb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM once the CI is fixed.
Another variable won't work, I just could use an alias (reference to ptr1), but I'm not sure it tricks all the modern compilers. It may work for now, but not anymore after compiler update. Could also be fixed by suppressing this compiler warning temporarily (if allowed). |
Sure, just remove the code in the unit tests that does not build, due to the self move warning. The operator= change in the header is simple enough, it does not absolutely require unit test coverage if this brings complications. |
6899531 to
588dbbd
Compare
marcalff
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the fix.
see #3713 (comment)
Fixes # (issue)
Changes
prevent self assignment and self move assignment
Please provide a brief description of the changes here.
For significant contributions please make sure you have completed the following items:
CHANGELOG.mdupdated for non-trivial changes