[libcxx-commits] [libcxx] [libc++][hardening] Categorize more assertions. (PR #75918)

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Fri Dec 22 12:11:23 PST 2023


================
@@ -65,8 +65,9 @@ template < class _InputIter,
 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 void advance(_InputIter& __i, _Distance __orig_n) {
   typedef typename iterator_traits<_InputIter>::difference_type _Difference;
   _Difference __n = static_cast<_Difference>(std::__convert_to_integral(__orig_n));
-  _LIBCPP_ASSERT_UNCATEGORIZED(__n >= 0 || __has_bidirectional_iterator_category<_InputIter>::value,
-                               "Attempt to advance(it, n) with negative n on a non-bidirectional iterator");
+    // Calling `advance` with a negative value on a non-bidirectional iterator in the current implementation.
+  _LIBCPP_ASSERT_PEDANTIC(__n >= 0 || __has_bidirectional_iterator_category<_InputIter>::value,
----------------
mordante wrote:

I would rate this higher than pedantic, I assume this is a real user bug and does the wrong thing.

Likewise for the similar changes.

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


More information about the libcxx-commits mailing list