<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/133056>133056</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[libc++] Instantiation of `pair` in class template argument deduction is a bit too eager
</td>
</tr>
<tr>
<th>Labels</th>
<td>
libc++
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
frederick-vs-ja
</td>
</tr>
</table>
<pre>
The following code snippet is rejected with libc++ ([Godbolt link](https://godbolt.org/z/q1x1E8Tqq)):
```C++
#include <utility>
#include <type_traits>
// note that *+[]{} dereferences a function pointer converted from the lambda expression
static_assert(std::is_same_v<decltype(std::pair{0, *+[]{}}), std::pair<int, void(*)()>>);
```
It seems that the related implicit deduction guide synthesized from the constructor (`pair(const T1&, const T2&) -> pair<T1, T2>`) should be excluded by SFINAE mechanisms before instantiating invalid `pair<int, void()>`, and the decaying explicit deduction guide (`pair(T1, T2) -> pair<T1, T2>`) should work.
But libc++ currently makes the instantiation a bit too eager, and then causes hard error. I've roughly verified that this can (and perhaps should) be fixed within the library implementation.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMVMFy4jgQ_Rpx6QplpAD2wQcgsJXLXjb3lCy1cU9kyZHaBObrt2TIDJnZrZqqrsJS09J7r59ap0RHj1iL5VYsn2Z65C7Euo1oMZJ5ezilh2961gR7qV86hDY4Fz7IH8EEi5A8DQMyUIKI39AwWvgg7sBRY4TcCrkFIUux3P4VbBMcgyP_JpZPQpYd85CE2gh5EPJwvObnIR6FPHwX8vC-OC_25cv7u5BVDrURxRSr4hq76wV5Syryxo0WQajdyOSIL0Ltf0vxZcBXjpo43dLF7X7wgRG40wxCbvKxkyBivRXrJ7AYscWI3mACDe3oDVPwMATyjBFM8CeMmX0bQw_cITjdN1YDnoeIKVHwotgk1kzmVaeEkYUsE9tMS20ovSbd4-tJqJ1F4zLO-_ygKYr1thBy9x_wcmSNdvC1QO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