-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
<string>
, <sstream>
: Is the _String_constructor_rvalue_allocator_tag
internal constructor necessary?
#4929
Comments
We talked about this at the weekly maintainer meeting, reading the relevant Standardese WG21-N4988 [stringbuf.members]/10:
Overall, we were mildly concerned about disrupting overload resolution for such a popular type with machinery not directly depicted in the Standard, even if it fixes highly pathological scenarios. We believe that virtually no code anywhere cares about whether an allocator is copy-constructed or move-constructed (even though move-constructing an allocator can theoretically transfer internal caching blah blah that doesn't participate in allocator equality). The (However, it's fine to move-construct allocators when doing so doesn't require extra internal machinery to be added, e.g. as we're doing in To summarize: We are in favor of removing this tagged constructor and simply copy-constructing the allocator here. We believe that this will simplify the codebase and real world code won't ever care about the difference. If anyone complains about this in the future, we can ask LWG to clarify the handwavy wording here. |
I've found that some allocators in libcxx's test suit intentionally behave differently between copy and move construction and such differences are being tested. |
We talked about that at the weekly maintainer meeting and @CaseyCarter said he wasn't super motivated by the possibility of a library test suite adding wacky allocators in the future. I said "we can cross that bridge if we come to it, we have plenty of libcxx skips and can always add more". Casey then mentioned that if we were concerned about node allocators, they can potentially have free-lists that benefit from moving, but this is an allocator for strings. |
When considering the bug reported in LLVM-101960 for MSVC STL, I found that in addition to
optional
, one internal constructor ofbasic_string
is buggy in a similar way (Godbolt link). The constructor was added by #919 in responding to review comments in #919 (comment).Example
STL/stl/inc/xstring
Lines 1148 to 1152 in 91e4255
Instead of fixing this constructor, I guess it might be better to remove it. As of LWG-2593, move construction must not change the value of the source allocator, so it's arguable that there shouldn't be observable difference between move and copy construction. But it seems allowed that side effects can be different.
There's a similar thing in
list
:STL/stl/inc/list
Lines 807 to 810 in 91e4255
The text was updated successfully, but these errors were encountered: