[libcxx-commits] [libcxx] [libcxx] Add assert into __set_long_cap (PR #90645)

Vitaly Buka via libcxx-commits libcxx-commits at lists.llvm.org
Tue Apr 30 11:20:54 PDT 2024


https://github.com/vitalybuka created https://github.com/llvm/llvm-project/pull/90645

None

>From 3d88874bd17fe8d0625566c406fca0f978cf653e Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Fri, 26 Apr 2024 15:03:40 -0700
Subject: [PATCH] [libcxx] Add assert into __set_long_cap

---
 libcxx/include/string | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libcxx/include/string b/libcxx/include/string
index 883bc1d7e5dc9f..c72241ff00acf8 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -1876,6 +1876,7 @@ private:
   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_long_cap(size_type __s) _NOEXCEPT {
     __r_.first().__l.__cap_     = __s / __endian_factor;
     __r_.first().__l.__is_long_ = true;
+    _LIBCPP_ASSERT_INTERNAL(__s == __get_long_cap(), "Size must be __endian_factor aligned.");
   }
 
   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __get_long_cap() const _NOEXCEPT {



More information about the libcxx-commits mailing list