[libcxx-commits] [PATCH] D88849: [libc++] Make sure __clear_and_shrink() maintains string invariants

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Oct 5 15:00:04 PDT 2020


ldionne updated this revision to Diff 296307.
ldionne added a comment.

Use value_type() when checking invariants.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88849/new/

https://reviews.llvm.org/D88849

Files:
  libcxx/include/string


Index: libcxx/include/string
===================================================================
--- libcxx/include/string
+++ libcxx/include/string
@@ -3941,7 +3941,7 @@
         return false;
     if (data() == 0)
         return false;
-    if (data()[size()] != value_type(0))
+    if (data()[size()] != value_type())
         return false;
     return true;
 }
@@ -3959,6 +3959,7 @@
         __alloc_traits::deallocate(__alloc(), __get_long_pointer(), capacity() + 1);
         __set_long_cap(0);
         __set_short_size(0);
+        traits_type::assign(*__get_short_pointer(), value_type());
     }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88849.296307.patch
Type: text/x-patch
Size: 612 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20201005/98e941b6/attachment.bin>


More information about the libcxx-commits mailing list