<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61254>61254</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang try to eagerly instantiate more things that needed
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:frontend
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
fsb4000
</td>
</tr>
</table>
<pre>
@EricWF wrote that the code should work, but it will stop working if we change `declval` to match the C++ standard.
```c++
template <class T>
__add_rvalue_reference(T) declval() noexcept {
static_assert(!__is_same(T, T),
"Calling declval is ill-formed, see [declval]/2.");
}
template <class T, class U, class = U[declval<T>()]>
constexpr bool xxx(int) {
return true;
}
template <class T, class U>
constexpr bool xxx(long) {
return false;
}
constexpr bool y = xxx<long long, int>(0);
```
https://gcc.godbolt.org/z/b8cxG89Mb
I've created the same issue for GCC.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyclMGSozYQhp-muXSNS26wgQOHGbxs5ZDbbuXoElIDSgRySWLGk6dPCXtqnE02h7hcIJD6-7t_WpIhmHFhbuDwAodTJtc4Od8MoS-EEFnv9HsDhfjijfqtwzfvImOcZMQ4MSqnGcPkVqvxzfk_gFrs14gm4puxFkN0l23CLCOaAd8Y1SSXkRGOQrOyr9LCUWB0OMuopg3aAr0AvWCIctHS6x2IE4jn-_Uobn91W3V7G3m-WBkZIW-VlSHgN8i_3ObOZ6n12b9Ku_LZ88CeF8VA1TegGj-SoCo9LY6vii8RobyTUxbRqLMMgX3clu3PZxPOQc53SIuJBNTeI_7xA6JWWps8uMuhCWisfRqcn1knRGBGOLx8pHM4AXW0A6KEzu_JQHl69OLfqqYWb8Pvn0PIT_j9AZ63mztbyUnpwynllhD5evHYO2fxer0CVWaJyZlPQxDRc1z9gtGv_D9z-09J65bxZ5qDtOGnoj_Q3rfKEzNvExNv4BZTTZsB4m_ufrTWI3KK8RIgfwbqgLpRqd3odO9s3Dk_AnV_AnV9pa5fq_rX_jHwF6DylVF5lpH11tipZdCEsDIOzuPXtt1lusl1ndcy42Z_LCsq9hUV2dTIsqzqYi-Opa7zI3NV1311GMRQ6Pqoin1mGhKUi1xUgvalKHYkVSnKutd7STlLDYXgWRq7s_Z1Ttlmm3Rz3NOhyKzs2YZt0xMpK5cR8ufBuyXyolPbHU6Zb1LoU7-OAQphTYjhExZNtNxgm0Ix-ve0h1mO7O07miXt3WjS95-dTweGWcZwOzcWZs06W71tfjDXxGntd8rNQF3Sud-eLt79zioCdVsFAajbivgrAAD__4v5bBE">