clang hangs when compiling generic lambda with -fdelayed-template-parsing

Hi all,

The simple code listed below will make clang hang with compiler option -fdelayed-template-parsing.

#include

template <typename Func, typename Args>
auto test_func_wrapper(Func const& func, Args const& args) {
return func(args);
}

void clang_bug_test() {
std::vector vecn{1,2,3};
auto f = [](auto const& vecn) → int {
return vecn[0];
};
test_func_wrapper(f, vecn);
}

int main() {
return 0;
}

It happens on my mac (Apple LLVM version 9.0.0 (clang-900.0.38)) and also on godbolt.org and wandbox.org with all clang versions.

If we remove the trailing return type of the generic lambda, it compiles.
If we don’t use vecn at all in the lambda and simply return 0, it also compiles.
If we remove the -fdelayed-template-parsing, it compiles.

Best regards,
Han

This is https://bugs.llvm.org/show_bug.cgi?id=33561