[libc++] Make sure basic_string::reserve(n) never shrinks in all Standard modes
Since basic_string::reserve(n) is instantiated in the shared library but also available to the compiler for inlining, its definition should not depend on things like the Standard mode in use. Indeed, that flag may not match between how the shared library is compiled and how users are compiling their own code, resulting in ODR violations. However, note that we retain the behavior of basic_string::reserve() to shrink the string for backwards compatibility reasons. While it would technically be conforming to not shrink, we believe user expectation is for it to shrink, and so existing code might have been written based on that assumption. We prefer to not break such code, even though that makes basic_string::reserve() and basic_string::reserve(0) not equivalent anymore. Fixes llvm-project#53170 Differential Revision: https://reviews.llvm.org/D117332
Loading
Please sign in to comment