http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59991
Bug ID: 59991 Summary: Recursive lambda capture in C++1y constexpr function template causes internal compiler error Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: pkeir at outlook dot com Created attachment 31987 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31987&action=edit The test case which produces the internal compiler error The code below uses the C++1y feature of allowing declarations in constexpr functions, but r should not be included in the lambda's capture list. There is also an issue with excessive recursive template instantiation. In any case, the code produces an internal compiler error starting with: internal compiler error: in tsubst, at cp/pt.c:11350 auto f = [r,x]() { return r(x); }; The full output and test case is attached. This was run under Ubuntu 13.10. // $ g++ --version // g++ (GCC) 4.9.0 20131201 (experimental) template <typename T> constexpr int r(T x) { auto f = [r,x]() { return r(x); }; return 0; } int main(int argc, char *argv[]) { r(0); return 0; }