<div dir="ltr">Hi all, <div><br></div><div>The simple code listed below will make clang hang with compiler option -fdelayed-template-parsing. <br><div><br></div><div>

<div style="color:rgb(0,0,0);background-color:rgb(255,255,254);font-family:monospace;font-weight:normal;font-size:14px;line-height:19px;white-space:pre"><div><span style="color:rgb(0,0,255)">#include</span><span style="color:rgb(0,0,0)"> <vector></span></div><br><div><span style="color:rgb(0,0,255)">template</span><span style="color:rgb(0,0,0)"> <</span><span style="color:rgb(0,0,255)">typename</span><span style="color:rgb(0,0,0)"> Func, </span><span style="color:rgb(0,0,255)">typename</span><span style="color:rgb(0,0,0)"> Args></span></div><div><span style="color:rgb(0,0,255)">auto</span><span style="color:rgb(0,0,0)"> test_func_wrapper(Func </span><span style="color:rgb(0,0,255)">const</span><span style="color:rgb(0,0,0)">& func, Args </span><span style="color:rgb(0,0,255)">const</span><span style="color:rgb(0,0,0)">& args) {</span></div><div><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,0,255)">return</span><span style="color:rgb(0,0,0)"> func(args);</span></div><div><span style="color:rgb(0,0,0)">}</span></div><br><div><span style="color:rgb(0,0,255)">void</span><span style="color:rgb(0,0,0)"> clang_bug_test() {</span></div><div><span style="color:rgb(0,0,0)">  std::vector<</span><span style="color:rgb(0,0,255)">int</span><span style="color:rgb(0,0,0)">> vecn{</span><span style="color:rgb(9,136,90)">1</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(9,136,90)">2</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(9,136,90)">3</span><span style="color:rgb(0,0,0)">};</span></div><div><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,0,255)">auto</span><span style="color:rgb(0,0,0)"> f = [](</span><span style="color:rgb(0,0,255)">auto</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,0,255)">const</span><span style="color:rgb(0,0,0)">& vecn) -> </span><span style="color:rgb(0,0,255)">int</span><span style="color:rgb(0,0,0)"> {</span></div><div><span style="color:rgb(0,0,0)">    </span><span style="color:rgb(0,0,255)">return</span><span style="color:rgb(0,0,0)"> vecn[</span><span style="color:rgb(9,136,90)">0</span><span style="color:rgb(0,0,0)">];</span></div><div><span style="color:rgb(0,0,0)">  };</span></div><div><span style="color:rgb(0,0,0)">  test_func_wrapper(f, vecn);</span></div><div><span style="color:rgb(0,0,0)">}</span></div><br><div><span style="color:rgb(0,0,255)">int</span><span style="color:rgb(0,0,0)"> main() {</span></div><div><span style="color:rgb(0,0,0)">  </span><span style="color:rgb(0,0,255)">return</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(9,136,90)">0</span><span style="color:rgb(0,0,0)">;</span></div><div><span style="color:rgb(0,0,0)">}</span></div></div>

<br></div><div>It happens on my mac (Apple LLVM version 9.0.0 (clang-900.0.38)) and also on <a href="http://godbolt.org">godbolt.org</a> and <a href="http://wandbox.org">wandbox.org</a> with all clang versions. </div><div><br></div><div>If we remove the trailing return type of the generic lambda, it compiles. </div><div>If we don't use vecn at all in the lambda and simply return 0, it also compiles. </div><div>If we remove the -fdelayed-template-parsing, it compiles.</div><div><br></div><div>Best regards,</div><div>Han</div></div></div>