[all-commits] [llvm/llvm-project] 479f99: [libc++] Fix `basic_string::shrink_to_fit` for con...
A. Jiang via All-commits
all-commits at lists.llvm.org
Wed Jun 4 16:24:11 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 479f9922912e3385655f0ca6e6238aaf09e6320d
https://github.com/llvm/llvm-project/commit/479f9922912e3385655f0ca6e6238aaf09e6320d
Author: A. Jiang <de34 at live.cn>
Date: 2025-06-05 (Thu, 05 Jun 2025)
Changed paths:
M libcxx/include/string
M libcxx/test/std/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp
Log Message:
-----------
[libc++] Fix `basic_string::shrink_to_fit` for constant evaluation (#142712)
Currently, when the string shrink into the SSO buffer, the `__rep_.__s`
member isn't activated before the `traits_type::copy` call
yet, so internal `__builtin_memmove` call writing to the buffer causes
constant evaluation failure. The existing test coverage seems a bit
defective and doesn't cover this case - `shrink_to_fit` is called on the
copy of string after erasure, not the original string object.
This PR reorders the `__set_short_size` call, which starts the lifetime
of the SSO buffer, before the copy operation. Test coverage is achieved
by calling `shrink_to_fit` on the original erased string.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list