Since basic_string::reserve 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.
A valid implementation of reserve() has always been to never shrink,
even before C++20. This patch uses that implementation freedom to resolve
the issue by always implementing the C++20 behavior.
Fixes llvm-project#53170
Consider reflowing to fit in Phab's column count. :)
"so that both these calls never shrink the string consistently in all Standard modes" — so they always shrink it inconsistently? 😛 Suggestion: