<div dir="rtl"><div dir="ltr">Hello,</div><div dir="ltr"><br></div><div dir="ltr">The following code causes endless recursion leading to seg fault with the latest SVN. </div><div dir="ltr"><br></div><div dir="ltr">clang tries to deduce g return type, which requires f return type, which requires g return type, repeats endlessly.</div>
<div dir="ltr"><br></div><div dir="ltr">If the templates are modified to regular functions taking double, clang correctly errors upon parse:</div><div dir="ltr">error: function 'g' with deduced return type cannot be used before it is defined</div>
<div dir="ltr"><div dir="ltr"> return x*g(x-1);</div></div><div dir="ltr"><br></div><div dir="ltr">but with templates there is no error parsing, just seg fault running.</div><div dir="ltr"><br></div><div dir="ltr">Yaron</div>
<div dir="ltr"><br></div><div dir="ltr"><br></div><div dir="ltr"><div dir="ltr"><font face="courier new, monospace">// Endless recursion with revision 190992.</font></div><div dir="ltr"><font face="courier new, monospace"><br>
</font></div><div dir="ltr"><font face="courier new, monospace">template <class T></font></div><div dir="ltr"><font face="courier new, monospace">auto g(T x);</font></div><div dir="ltr"><font face="courier new, monospace"><br>
</font></div><div dir="ltr"><font face="courier new, monospace">template <class T></font></div><div dir="ltr"><font face="courier new, monospace">auto f(T x) {</font></div><div dir="ltr"><font face="courier new, monospace"> if (x>0)</font></div>
<div dir="ltr"><font face="courier new, monospace"> return x*g(x-1);</font></div><div dir="ltr"><font face="courier new, monospace"> else</font></div><div dir="ltr"><font face="courier new, monospace"> return 1.0;</font></div>
<div dir="ltr"><font face="courier new, monospace">}</font></div><div dir="ltr"><font face="courier new, monospace"><br></font></div><div dir="ltr"><font face="courier new, monospace">template <class T></font></div>
<div dir="ltr"><font face="courier new, monospace">auto g(T x) {</font></div><div dir="ltr"><font face="courier new, monospace"> if (x>0)</font></div><div dir="ltr"><font face="courier new, monospace"> return x*f(x-1);</font></div>
<div dir="ltr"><font face="courier new, monospace"> else</font></div><div dir="ltr"><font face="courier new, monospace"> return 1.0;</font></div><div dir="ltr"><font face="courier new, monospace">}</font></div><div><font face="courier new, monospace"><br>
</font></div><div><font face="courier new, monospace">int main() {</font></div><div><font face="courier new, monospace"> f(9.0);</font></div><div><font face="courier new, monospace">}</font></div><div><br></div></div></div>