Skip to content
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

<xstring>: Fix basic_string::operator=(const&) thoroughly #3997

Closed
achabense opened this issue Aug 28, 2023 · 2 comments · Fixed by #4031
Closed

<xstring>: Fix basic_string::operator=(const&) thoroughly #3997

achabense opened this issue Aug 28, 2023 · 2 comments · Fixed by #4031
Labels
bug Something isn't working fixed Something works now, yay!

Comments

@achabense
Copy link
Contributor

achabense commented Aug 28, 2023

basic_string::operator=(const&) is still problematic even after #3862. For example:

STL/stl/inc/xstring

Lines 3170 to 3175 in 60f1885

_Traits::copy(_Unfancy(_New_ptr), _Right_ptr, _Right_size + 1);
_Tidy_deallocate();
_Mypair._Myval2._Bx._Ptr = _New_ptr;
_Mypair._Myval2._Mysize = _Right_size;
_Mypair._Myval2._Myres = _New_capacity;
} else {

  1. After _Tidy_deallocate the string is left in SSO mode, so the pointer should be constructed instead of assigned.
  2. The new allocation lacks ASAN annotation.

These are what I can find. As the branch is in such a broken state, I'm uncertain whether there are other problems.

@frederick-vs-ja
Copy link
Contributor

frederick-vs-ja commented Aug 28, 2023

1. After _Tidy_deallocate the string is left in SSO mode, so the pointer should be constructed instead of assigned.

Yes. It seems that there should be test coverage for non-trivial (but constexpr-friendly) fancy pointers.
(I roughly remember that I've invented more than one kinds of fancy pointers for testing.)

@CaseyCarter CaseyCarter added the bug Something isn't working label Aug 29, 2023
@achabense

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed Something works now, yay!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants