<vector>: Fix allocator types in reallocation guards
#5729
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reported by Weipeng Liu internally. Consider the following code, which is activating our escape hatch to disable enforcement of WG21-N5014 [container.alloc.reqmts]/5 "Mandates:
allocator_type::value_typeis the same asX::value_type."Although I grumbled at the use of our escape hatch allowing non-conformantly mismatched allocators, Weipeng identified the problem -
vector's reallocation guards mention the wrong allocator type. In STL containers, we have a convention that_Allocis the user's original allocator, while_Altyis the properly rebound allocator. The reallocation guards refer to original_Alloc, contrary to our convention.This was introduced by #4977 on 2024-10-11 in VS 2022 17.13, so it's a recent regression.
Because the reallocation guard types are used locally within member functions, we can fix this in an ABI-compatible way by renaming the guard types while fixing the allocator reference types.
I am not adding test coverage because we have none for the escape hatch, and this fix is unlikely to accidentally regress again.