[libc++] [LIBCXX-DEBUG-FIXME] std::advance shouldn't use ADL `>=` on the _Distance...
authorArthur O'Dwyer <arthur.j.odwyer@gmail.com>
Tue, 20 Apr 2021 19:59:22 +0000 (15:59 -0400)
committerArthur O'Dwyer <arthur.j.odwyer@gmail.com>
Wed, 5 May 2021 20:21:09 +0000 (16:21 -0400)
Convert to a primitive type first; then use primitive `>=` on that value.

Differential Revision: https://reviews.llvm.org/D101678

libcxx/include/iterator
libcxx/test/std/iterators/iterator.primitives/iterator.operations/robust_against_adl.pass.cpp

index ad98d8c..1d308a2 100644 (file)
@@ -538,10 +538,10 @@ template <class _InputIter, class _Distance>
 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
 void advance(_InputIter& __i, _Distance __orig_n)
 {
-    _LIBCPP_ASSERT(__orig_n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value,
-                   "Attempt to advance(it, n) with negative n on a non-bidirectional iterator");
     typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
     _IntegralSize __n = __orig_n;
+    _LIBCPP_ASSERT(__n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value,
+                   "Attempt to advance(it, n) with negative n on a non-bidirectional iterator");
     _VSTD::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category());
 }