<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/65620>65620</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
libc++ makes wrong assumptions in std::pair constructor
</td>
</tr>
<tr>
<th>Labels</th>
<td>
libc++,
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
grisumbras
</td>
</tr>
</table>
<pre>
With latest libc++ this code doesn't compile in clang with `-std=c++23`.
```c++
#include <type_traits>
#include <utility>
struct kvp {
kvp() = default;
explicit kvp(std::pair<int, int> const& p);
};
namespace std {
template <>
struct tuple_size<kvp> : std::integral_constant<std::size_t, 2> {};
template <>
struct tuple_element<0, kvp> {
using type = int;
};
template <>
struct tuple_element<1, kvp> {
using type = int;
};
} // namespace std
static_assert(std::is_nothrow_move_constructible<kvp>::value);
```
As far as I can tell, when checking wether `kvp` is nothrow move constructible, the compiler tries instantiating this `std::pair` constructor( https://github.com/llvm/llvm-project/blob/main/libcxx/include/__utility/pair.h#L286-L291 ).
That in turn tries to compile this code (https://github.com/llvm/llvm-project/blob/main/libcxx/include/__utility/pair.h#L279-L282), which assumes that `std::tuple_size<T>::value == 2` means that `std::get<0>(T)` and `std::get<1>(T)` will work.
For context, in the original code this type had `get` overloads in its own namespace, but not in namespace `std`.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VUFr8zgQ_TWTy9CgjBPHPvjQJg0sfMcP9hhkW7W1lSUjjZt2f_0ixY0btsvywbJQ5MYazTy9eW8sQ9CdVaqC3RPsjis5ce981XkdpqH2Mqxq135Uv2vu0UhWgdHougF6AnpC7nXAxrUKW6eCBdozNm4YtVGoLTZG2g4v8SxCLh4Ct5Ad58OUQS7WII4gHuc1F9e_OWJ-S5m2jZlahZAd-GNUZ_ZSc4Ds-buIibXR_LHspjWwnxrG17cRYT9nxvgTqAAqEbIjtupFToYhu-2r99HoRvMcmPA_QvY4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