[Bug c++/69222] New: C++14 template code working in GCC 5.1 stops working in 5.2 and 5.3
wuyongwei at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Jan 11 02:48:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69222
Bug ID: 69222
Summary: C++14 template code working in GCC 5.1 stops working
in 5.2 and 5.3
Product: gcc
Version: 5.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: wuyongwei at gmail dot com
Target Milestone: ---
Created attachment 37299
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37299&action=edit
Test C++ file
I have an implementation of Y Combinator in C++, which works in GCC 4.9 to 5.1
as well as Clang 3.5 (in C++14 mode). It stops working in GCC 5.2 and 5.3, so I
think it is regression. I think GCC is being too eager in template
instantiation. As I also tried using the GCC 5.1 C++ header files with GCC 5.2
and got the same errors, I guess it is a C++ front end problem.
The test program is supposed to apply the Y combinator to a non-recursive
function almost_fac to get a factorial function. It should compile well and
output two lines of "120", but now it fails the compilation at the
"fix_curry(almost_fac)" line.
I tested on Windows and OS X. The Windows error output is:
In file included from test_gcc.cpp:1:0:
C:/mingw64/x86_64-w64-mingw32/include/c++/functional: In substitution of
'template<class _Functor, class> std::function<_Res(_ArgTypes
...)>::function(_Functor) [with _Functor =
std::function<std::function<int(int)>(self_ref_func<std::function<int(int)>
>)>; <template-parameter-1-2> = <missing>]':
C:/mingw64/x86_64-w64-mingw32/include/c++/functional:1981:45: recursively
required by substitution of 'template<class _Functor, class>
std::function<_Res(_ArgTypes ...)>::function(_Functor) [with _Functor =
std::function<std::function<int(int)>(self_ref_func<std::function<int(int)>
>)>; <template-parameter-1-2> = <missing>]'
C:/mingw64/x86_64-w64-mingw32/include/c++/functional:1981:45: required by
substitution of 'template<class _Functor, class> std::function<_Res(_ArgTypes
...)>::function(_Functor) [with _Functor =
std::function<std::function<int(int)>(self_ref_func<std::function<int(int)>
>)>; <template-parameter-1-2> = <missing>]'
test_gcc.cpp:47:51: required from
'fix_curry(std::function<std::function<_Rs(_Tp)>(std::function<_Rs(_Tp)>)>)::<lambda(fn_self_ref)>::<lambda(_Tp&&)>
[with _Rs = int; _Tp = int]'
test_gcc.cpp:45:34: required from 'struct
fix_curry(std::function<std::function<_Rs(_Tp)>(std::function<_Rs(_Tp)>)>)::<lambda(fn_self_ref)>
[with _Rs = int; _Tp = int; fn_self_ref = self_ref_func<std::function<int(int)>
>]::<lambda(int&&)>'
test_gcc.cpp:45:21: required from
'fix_curry(std::function<std::function<_Rs(_Tp)>(std::function<_Rs(_Tp)>)>)::<lambda(fn_self_ref)>
[with _Rs = int; _Tp = int; fn_self_ref = self_ref_func<std::function<int(int)>
>]'
test_gcc.cpp:43:10: required from 'struct
fix_curry(std::function<std::function<_Rs(_Tp)>(std::function<_Rs(_Tp)>)>)
[with _Rs = int; _Tp = int]::<lambda(fn_self_ref)>'
test_gcc.cpp:50:5: required from 'std::function<_Rs(_Tp)>
fix_curry(std::function<std::function<_Rs(_Tp)>(std::function<_Rs(_Tp)>)>)
[with _Rs = int; _Tp = int]'
test_gcc.cpp:69:43: required from here
C:/mingw64/x86_64-w64-mingw32/include/c++/functional:1981:69: fatal error:
template instantiation depth exceeds maximum of 900 (use -ftemplate-depth= to
increase the maximum)
using _Invoke = decltype(__callable_functor(std::declval<_Functor&>())
^
compilation terminated.
More information about the Gcc-bugs
mailing list