Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@AlexGuteniev
Copy link
Contributor

Towards #1485.

On self-assignment, including self-move-assignment, any resets to empty, then calls _Move_from on itself, which treats empty any as _Any_representation::_Trivial and does self-memcpy.

Self-memcpy does seem unacceptably squirrely.

There are number of ways to fix this issue. We can do this check directly in operator=s, to avoid any other potential impact. Or we can do the check for empty any directly in _Move_from, to optimize other empty any assignment in addition.

I've arbitrarily chosen to do this in _Assign, to keep ruining the any that is being self-assigned, do it in just one place, and not do any changes beyond the needed.

@AlexGuteniev AlexGuteniev requested a review from a team as a code owner April 17, 2025 20:58
@github-project-automation github-project-automation bot moved this to Initial Review in STL Code Reviews Apr 17, 2025
@AlexGuteniev
Copy link
Contributor Author

AlexGuteniev commented Apr 17, 2025

Actually I was wrong, _Assign takes any by value, so it is never self-memcpy

@github-project-automation github-project-automation bot moved this from Initial Review to Done in STL Code Reviews Apr 17, 2025
@AlexGuteniev AlexGuteniev deleted the any-but-this branch April 17, 2025 21:03
@frederick-vs-ja
Copy link
Contributor

FYI #3965 fixed some bugs around self assignment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants