[libcxx-commits] [libcxx] [libc++] Fix incorrect size check when growing std::string (PR #232737)
Raphael Isemann via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Oct 22 02:11:41 PDT 2026
Teemperor wrote:
I think this broke libc++ compilation on [a macOS bot](https://ci.swift.org/view/all/job/llvm.org/job/as-lldb-cmake/14222/console):
```cpp
09:33:21 [31/1522] Building CXX object libcxx/src/CMakeFiles/cxx_shared.dir/locale.cpp.o
09:33:21 FAILED: [code=1] libcxx/src/CMakeFiles/cxx_shared.dir/locale.cpp.o
09:33:21 /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/bin/clang++ --target=arm64-apple-darwin25.2.0 -DLIBCXX_BUILDING_LIBCXXABI -DLIBC_NAMESPACE=__llvm_libc_common_utils -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION=2 -D_LIBCPP_BUILDING_LIBRARY -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/libcxx/src -I/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/include/c++/v1 -I/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/libcxxabi/include -isystem /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/cmake/Modules/../../libc -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wno-pass-failed -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -Xclang -fno-pch-timestamp -O3 -DNDEBUG -isysroot /Applications/Xcode_26.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.2.sdk -fPIC -UNDEBUG -std=c++26 -faligned-allocation -nostdinc++ -fvisibility-inlines-hidden -fvisibility=hidden -fsized-deallocation -Wall -Wextra -Wnewline-eof -Wshadow -Wwrite-strings -Wno-unused-parameter -Wno-long-long -Werror=return-type -Wextra-semi -Wundef -Wunused-template -Wformat-nonliteral -Wzero-length-array -Wdeprecated-redundant-constexpr-static-def -Wno-nullability-completeness -Wmissing-prototypes -Wno-user-defined-literals -Wno-covered-switch-default -Wno-suggest-override -Wno-error -fdebug-prefix-map=/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/include/c++/v1=/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/libcxx/include -MD -MT libcxx/src/CMakeFiles/cxx_shared.dir/locale.cpp.o -MF libcxx/src/CMakeFiles/cxx_shared.dir/locale.cpp.o.d -o libcxx/src/CMakeFiles/cxx_shared.dir/locale.cpp.o -c /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/libcxx/src/locale.cpp
09:33:21 In file included from /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/libcxx/src/locale.cpp:12:
09:33:21 In file included from /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/include/c++/v1/codecvt:64:
09:33:21 In file included from /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/include/c++/v1/__locale_dir/codecvt.h:17:
09:33:21 In file included from /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/include/c++/v1/__locale_dir/locale.h:27:
09:33:21 /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/include/c++/v1/string:2941:96: error: too few arguments to function call, expected 2, have 1
09:33:21 2941 | __long __buffer = __allocate_long_buffer(__alloc_, __n, __get_amortized_growth_capacity(__n));
09:33:21 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
09:33:21 /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/include/c++/v1/string:1492:7: note: in instantiation of function template specialization 'std::basic_string<wchar_t>::__assign_trivial<wchar_t *, wchar_t *>' requested here
09:33:21 1492 | __assign_trivial(__first, __last, __n);
09:33:21 | ^
09:33:21 /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/libcxx/src/locale.cpp:4621:17: note: in instantiation of function template specialization 'std::basic_string<wchar_t>::assign<wchar_t *, 0>' requested here
09:33:21 4621 | __weeks_[i].assign(wbuf, wbe);
09:33:21 | ^
09:33:21 /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/include/c++/v1/string:2309:3: note: '__get_amortized_growth_capacity' declared here
09:33:21 2309 | __get_amortized_growth_capacity(size_type __old_cap, size_type __additional_characters) {
09:33:21 | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
09:33:21 1 error generated.
```
https://github.com/llvm/llvm-project/pull/232737
More information about the libcxx-commits
mailing list