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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Hans Wennborg via cfe-dev
Hi all, 

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

#include <vector>

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

void clang_bug_test() {
std::vector<int> 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

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

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

Hans Wennborg via cfe-dev

On Thu, Feb 15, 2018 at 5:11 AM, Han Wang via cfe-dev <[hidden email]> wrote:
Hi all, 

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

#include <vector>

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

void clang_bug_test() {
std::vector<int> 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

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev