<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63391>63391</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang++: Surprising SFINAE behavior for default function parameters
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
akrzemi1
</td>
</tr>
</table>
<pre>
Clang 16 fails to compile the following program due to malformed default function argument:
```c++
template <typename U>
int fun(U u = U::value);
template <class T>
decltype(fun<T>()) test(int) { return 2; }
template<class>
int test(long) { return 3; }
int main() {
return test<int>(0);
}
```
GCC and MSVC compile the program that returns value 3. ICX exposes the same behavior as Clang. I would expect the GCC behavior.
1. Either the formation of the default function argument is not in the immediate context, and in this case there is no need to form the value: it should be enough to say that some default value would be produced (program would return 2),
2. Or it should be in the immediate context, and in this case the program should correctly diagnose that `fun<T>()` is invalid expression, substitution should fail, and the program should return 3.
Or am I mising something here?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVMmSpDYQ_RpxyRgCpCoKDhyq6C5HH-w5tMfhq4AEZGshtHRP--sdEkUvnvZhIohalE_v5fJI7pyYNWJLjhdyvMt48IuxLf_b_oNKlFlvxpe2k1zPUFYwcSEdeAODUauQCH5BmIyU5lnoGVZrZssVjAEjSHE5GatwhBEnHqSHKejBC6OB2zko1J6wMynuSLF_VsX2DIRe4pNOPapVco9AWOdfVtRcIXwj7H4LC52ICa2_QQDC7mLsTNj5icuAhDaEXd6LvKcbJHcOfn_lGnGQUYLQOlKyLoVoHVloAx6dJ7QW2sd_5HQBiz5YDZSwC5DT3Wc6uwxh9_CW8Y1KGj3_h4t9whVvKC70lkpCbwEA2O8lRtbF5FLOxYfSX_n2Fr-n_6XrgOsRfn38o_sw232ifuH-puMg9RVYDg_dn4DfV-PQJbSLg-lx4U_CWOAOknFyeIBnE-QYsTj4BI2KOzJ_nwqUOdwLv6C9mcsqnixjpnTwv1YC4UAbD0InnFAKRxHHPBjt8bsndKsxxYWDgbtUo8XtJmjEMdo2SiaKzT_sDMKDW1IFPQJqE-YlAh1_2RrjjHpLbOvO8w5frRnDgCMQWu_d3IKv1one6m7V0xy-2o-CP1vQ69BuFIOxFgcvX2AUfNYmobgHUhU_eLwqYjOEfuJSpHlZdE4YHbVc6J0XPqSu37jjQtjz-ER6d_SHCX-1wBU8gBIuLo3YPL_EX3EWhF2zsWVjwxqeYVtW9alsTlVVZEt7ONasP4ysLg-0PNSnqq-O01Cd-gGnQ9MXmWhpQVlRlU1ZF8WR5k3NKBuHmk9NWZVVTQ4FKi5kLuWTyo2dM-FcwLZirCkzyXuUbt-Eto2gL32YHTkUUjjv3q554SW2Q7T3bVOxMzwGu9qtqMfrw2_n-7d3YTL2R-eu3HKFHq2DLFjZLt6vLq4ueiX0Ogu_hD4fjCL0GoVvX19Wa_7CwRN6Tck7Qq8p_38DAAD__53g2pM">