[clang] [llvm] [ADT] Fix SmallVector append with input iterators (PR #191030)

Mikael Holmen via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 10 03:59:35 PDT 2026


mikaelholmen wrote:

Hello @aengelke 

I get the following when I compile the updated llvm/unittests/ADT/SmallVectorTest.cpp with gcc (13.2.0):
```
In file included from /app/vbuild/RHEL8-x86_64/gcc/13.2.0/include/c++/13.2.0/debug/stl_iterator.h:32,
                 from /app/vbuild/RHEL8-x86_64/gcc/13.2.0/include/c++/13.2.0/bits/stl_iterator.h:3004,
                 from /app/vbuild/RHEL8-x86_64/gcc/13.2.0/include/c++/13.2.0/iterator:63,
                 from ../include/llvm/ADT/ADL.h:13,
                 from ../include/llvm/ADT/SmallVector.h:17,
                 from ../unittests/ADT/SmallVectorTest.cpp:13:
/app/vbuild/RHEL8-x86_64/gcc/13.2.0/include/c++/13.2.0/debug/helper_functions.h: In instantiation of 'constexpr bool __gnu_debug::__valid_range_aux(_InputIterator, _InputIterator, std::input_iterator_tag) [with _InputIterator = {anonymous}::input_iterator]':
/app/vbuild/RHEL8-x86_64/gcc/13.2.0/include/c++/13.2.0/debug/helper_functions.h:208:42:   required from 'bool __gnu_debug::__valid_range_aux(_InputIterator, _InputIterator, typename _Distance_traits<_Iterator>::__type&, std::__false_type) [with _InputIterator = {anonymous}::input_iterator; typename _Distance_traits<_Iterator>::__type = std::pair<int, _Distance_precision>; typename std::__is_integer<_Tp>::__type = std::__is_integer<{anonymous}::input_iterator>::__type]'
/app/vbuild/RHEL8-x86_64/gcc/13.2.0/include/c++/13.2.0/debug/helper_functions.h:243:44:   required from 'bool __gnu_debug::__valid_range(_InputIterator, _InputIterator, typename _Distance_traits<_Iterator>::__type&) [with _InputIterator = {anonymous}::input_iterator; typename _Distance_traits<_Iterator>::__type = std::pair<int, _Distance_precision>; typename std::__is_integer<_Tp>::__type = std::__is_integer<{anonymous}::input_iterator>::__type]'
/app/vbuild/RHEL8-x86_64/gcc/13.2.0/include/c++/13.2.0/bits/stl_algobase.h:630:7:   required from '_OI std::copy(_II, _II, _OI) [with _II = {anonymous}::input_iterator; _OI = {anonymous}::Constructable*]'
../include/llvm/ADT/SmallVector.h:936:16:   required from 'llvm::SmallVectorImpl<T>::iterator llvm::SmallVectorImpl<T>::insert(iterator, ItTy, ItTy) [with ItTy = {anonymous}::input_iterator; <template-parameter-2-2> = void; T = {anonymous}::Constructable; iterator = {anonymous}::Constructable*]'
../unittests/ADT/SmallVectorTest.cpp:575:11:   required from 'void {anonymous}::SmallVectorTest_InsertInputIterator_Test<gtest_TypeParam_>::TestBody() [with gtest_TypeParam_ = llvm::SmallVector<{anonymous}::Constructable, 2>]'
../unittests/ADT/SmallVectorTest.cpp:566:1:   required from here
/app/vbuild/RHEL8-x86_64/gcc/13.2.0/include/c++/13.2.0/debug/helper_functions.h:172:22: error: no match for 'operator==' (operand types are '{anonymous}::input_iterator' and '{anonymous}::input_iterator')
  172 |       return __first == __last
      |              ~~~~~~~~^~~~~~~~~
/app/vbuild/RHEL8-x86_64/gcc/13.2.0/include/c++/13.2.0/debug/helper_functions.h: In instantiation of 'constexpr typename __gnu_debug::_Distance_traits<_Iterator>::__type __gnu_debug::__get_distance(_Iterator, _Iterator, std::input_iterator_tag) [with _Iterator = {anonymous}::input_iterator; typename _Distance_traits<_Iterator>::__type = std::pair<int, _Distance_precision>; typename std::__is_integer<_Tp>::__type = std::__is_integer<{anonymous}::input_iterator>::__type]':
/app/vbuild/RHEL8-x86_64/gcc/13.2.0/include/c++/13.2.0/debug/helper_functions.h:115:41:   required from 'constexpr typename __gnu_debug::_Distance_traits<_Iterator>::__type __gnu_debug::__get_distance(_Iterator, _Iterator) [with _Iterator = {anonymous}::input_iterator; typename _Distance_traits<_Iterator>::__type = std::pair<int, _Distance_precision>; typename std::__is_integer<_Tp>::__type = std::__is_integer<{anonymous}::input_iterator>::__type]'
/app/vbuild/RHEL8-x86_64/gcc/13.2.0/include/c++/13.2.0/debug/helper_functions.h:212:43:   required from 'bool __gnu_debug::__valid_range_aux(_InputIterator, _InputIterator, typename _Distance_traits<_Iterator>::__type&, std::__false_type) [with _InputIterator = {anonymous}::input_iterator; typename _Distance_traits<_Iterator>::__type = std::pair<int, _Distance_precision>; typename std::__is_integer<_Tp>::__type = std::__is_integer<{anonymous}::input_iterator>::__type]'
/app/vbuild/RHEL8-x86_64/gcc/13.2.0/include/c++/13.2.0/debug/helper_functions.h:243:44:   required from 'bool __gnu_debug::__valid_range(_InputIterator, _InputIterator, typename _Distance_traits<_Iterator>::__type&) [with _InputIterator = {anonymous}::input_iterator; typename _Distance_traits<_Iterator>::__type = std::pair<int, _Distance_precision>; typename std::__is_integer<_Tp>::__type = std::__is_integer<{anonymous}::input_iterator>::__type]'
/app/vbuild/RHEL8-x86_64/gcc/13.2.0/include/c++/13.2.0/bits/stl_algobase.h:630:7:   required from '_OI std::copy(_II, _II, _OI) [with _II = {anonymous}::input_iterator; _OI = {anonymous}::Constructable*]'
../include/llvm/ADT/SmallVector.h:936:16:   required from 'llvm::SmallVectorImpl<T>::iterator llvm::SmallVectorImpl<T>::insert(iterator, ItTy, ItTy) [with ItTy = {anonymous}::input_iterator; <template-parameter-2-2> = void; T = {anonymous}::Constructable; iterator = {anonymous}::Constructable*]'
../unittests/ADT/SmallVectorTest.cpp:575:11:   required from 'void {anonymous}::SmallVectorTest_InsertInputIterator_Test<gtest_TypeParam_>::TestBody() [with gtest_TypeParam_ = llvm::SmallVector<{anonymous}::Constructable, 2>]'
../unittests/ADT/SmallVectorTest.cpp:566:1:   required from here
/app/vbuild/RHEL8-x86_64/gcc/13.2.0/include/c++/13.2.0/debug/helper_functions.h:104:17: error: no match for 'operator==' (operand types are '{anonymous}::input_iterator' and '{anonymous}::input_iterator')
  104 |       if (__lhs == __rhs)
      |           ~~~~~~^~~~~~~~
ninja: build stopped: subcommand failed.
```
Does this make any sense to you?

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


More information about the cfe-commits mailing list