[libcxx-commits] [libcxx] [libc++] Fix `basic_string::shrink_to_fit` for constant evaluation (PR #142712)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jun 4 01:18:07 PDT 2025


https://github.com/philnik777 approved this pull request.

> Currently, when the string shrink into the SSO buffer, the lifetime of the buffer hasn't begun before copying characters into it, so the subsequent copy operation raises UB and thus causes constant evaluation failure.

This is incorrect. It's not UB, since we know that `CharT` is an implicit lifetime type, so we start the lifetime when copying the elements.

LGTM with updated commit message.

https://github.com/llvm/llvm-project/pull/142712


More information about the libcxx-commits mailing list