[all-commits] [llvm/llvm-project] 0407ab: [libc++] Make sure basic_string::reserve(n) never ...
Louis Dionne via All-commits
all-commits at lists.llvm.org
Mon Jan 24 12:43:28 PST 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 0407ab4114dbdbd1845df712639bdbc84ec6df2c
https://github.com/llvm/llvm-project/commit/0407ab4114dbdbd1845df712639bdbc84ec6df2c
Author: Louis Dionne <ldionne.2 at gmail.com>
Date: 2022-01-24 (Mon, 24 Jan 2022)
Changed paths:
M libcxx/docs/ReleaseNotes.rst
M libcxx/include/string
A libcxx/test/libcxx/strings/basic.string/string.capacity/PR53170.pass.cpp
R libcxx/test/libcxx/strings/basic.string/string.capacity/reserve.pass.cpp
Log Message:
-----------
[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
More information about the All-commits
mailing list