<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/74756>74756</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[libc++][test] `overload_compare_iterator` doesn't support its claimed `iterator_category`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
libc++
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
StephanTLavavej
</td>
</tr>
</table>
<pre>
There's an `overload_compare_iterator` that wraps an `Iterator` and claims to have the same `iterator_category`:
https://github.com/llvm/llvm-project/blob/2b1c76c7c4d62f4470fe1527bf239f380c19760a/libcxx/test/std/utilities/memory/specialized.algorithms/overload_compare_iterator.h#L18-L28
However, it totally doesn't support enough operations. When passed to MSVC's STL, we notice that `overload_compare_iterator<int *>` claims to be random-access and we try to subtract it, which fails to compile:
```
In file included from D:\GitHub\STL\llvm-project\libcxx\test\std\utilities\memory\specialized.algorithms\uninitialized.copy\uninitialized_copy.pass.cpp:16:
In file included from D:\GitHub\STL\out\x64\out\inc\memory:14:
In file included from D:\GitHub\STL\out\x64\out\inc\xmemory:15:
D:\GitHub\STL\out\x64\out\inc\xutility(1344,58): error: invalid operands to binary expression ('const overload_compare_iterator<int *>' and 'const overload_compare_iterator<int *>')
return static_cast<_Iter_diff_t<_Checked>>(_Last - _First);
~~~~~ ^ ~~~~~~
D:\GitHub\STL\out\x64\out\inc\xmemory(1923,49): note: in instantiation of function template specialization 'std::_Idl_distance<overload_compare_iterator<int *>, overload_compare_iterator<int *>>' requested here
auto _UDest = _Get_unwrapped_n(_Dest, _Idl_distance<_InIt>(_UFirst, _ULast));
^
D:\GitHub\STL\llvm-project\libcxx\test\std\utilities\memory\specialized.algorithms\uninitialized.copy\uninitialized_copy.pass.cpp(100,18): note: in instantiation of function template specialization 'std::uninitialized_copy<overload_compare_iterator<int *>, int *>' requested here
std::uninitialized_copy(Iterator(array), Iterator(array + N), p);
^
1 error generated.
```
</p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