[libcxx-commits] [libcxx] [libc++][hardening] Categorize assertions that produce incorrect results (PR #77183)

Konstantin Varlamov via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jan 6 00:01:48 PST 2024


================
@@ -307,8 +307,11 @@ public:
       : __data_(__s),
         __size_(__len) {
 #if _LIBCPP_STD_VER >= 14
-    _LIBCPP_ASSERT_UNCATEGORIZED(__len <= static_cast<size_type>(numeric_limits<difference_type>::max()),
-                                 "string_view::string_view(_CharT *, size_t): length does not fit in difference_type");
+    // This will result in creating an invalid `string_view` object -- some calculations involving `size` would
----------------
var-const wrote:

Note: while a few of these involve integer overflow, I don't think it's a good criterion for classification. To me, it seems very implementation-centric -- the fact that there is an overflow involved doesn't say much about the actual issue that will happen, which can range from something very minor or even benign to compromizing the memory safety of the program.

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


More information about the libcxx-commits mailing list