<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/141686>141686</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Templated infinitely recursive function does not fail to compile
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
alexkaratarakis
</td>
</tr>
</table>
<pre>
Min repro:
```C++
template <typename R1>
static R1 self_recursion_template(const R1& input)
{
return self_recursion_template<R1>(input);
}
static int self_recursion_non_template(const int& input)
{
return self_recursion_non_template(input);
}
int main()
{
int input{};
const int result = self_recursion_template(input);
// const int result = self_recursion_non_template(input); // Properly fails to compile
(void)result;
}
```
Expected results: compilation fails for the templated version of infinite self-recursion like it does for the non-templated version of infinite self-recursion.
Actual results: compiles and then stack overflows when trying to run it.
Additionally, `msvc` rejects the code.
Demo: https://godbolt.org/z/eEq7PT771
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUlE1vozwQxz-NuYwSgR0COXDIS3N7pKrqvXLMkPiJsVl7SJv99CtDSnez29VWskBg5vf_zwuWIeijRaxYvmH5LpE9nZyvpMG3s_SSpJdnHZKDq6_Vf9qCx847JtYsXbNlOq4t45u40jVh2xlJCExs6dqhlS3CU8bEA0vXgSRpBU8ZBDTNi0fV-6CdfXmPYrxUzgaKEXwJ2nY9Mb6KUkWkAwB4pN7bTwliO6rxcooWmwGwi9fJhLZ0z7B_cqItfdHKHeYTG1G_ldoyXt5j49YYVWzi92NguobJEXgMvSFgYveXUv6qHMmM7xnf_xPn8ywmzKN3HXpzhUZqE4AcKNd22mBUY7y8OF0zvho17tKfRmd8fHjrUBHWN0OBifUNJkk7e1NonAc6Ibz7quGCg1twDWjbaKsJh0RmUyJg9BlBE9QOPwjW2dlXKPPR5lpRL83vJjGAtHUkWwgk1RncBX1j3GuA1_iS_FXbYyyR7y1ouvEisq51TFEac2V8C2yZtuGi2DIFj_-jojAYVq7Gj6AdtvEXhBNRF22MDTm6-uAMzZ0_Mr7_zvgeH74Vj89FkSV1JeqVWMkEq6xYlKIsszJLTpUqUahaCSzTZlHkUogmw-aQyxwPq3wlEl3xlOdpzgsuuEizuSyWBedNU6S1kFmu2CLFVmozN-bSRu1Eh9BjlS2yZblMjDygCcPhwrnFVxh2GefxrPFVDJod-mNgi9ToQOEDQ5oMVs9Tl95bY65w68sFoemtGiZkaK91NIzKT7OY9N5Ud3XSdOoPc-VaxvdR7nabdd7FijO-H0wGxve3LC4V_xEAAP__aqiwNA">