[cfe-users] how to stop inlining a recursive template function
Larry Evans
cppljevans at suddenlink.net
Tue Dec 30 11:03:44 PST 2014
With:
http://llvm.org/releases/3.5.0/clang+llvm-3.5.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz
downloaded on:
2014-11-03.2250
and with the compile command:
/dwnlds/llvm/3.5/binary/clang+llvm-3.5.0-x86_64-linux-gnu/bin/clang++ -c
-O0 -g -stdlib=libc++ -std=c++14 -ftemplate-backtrace-limit=0
-I/home/evansl/prog_dev/boost/sandbox/rw/non_variadic_templates
-I/home/evansl/prog_dev/boost/boost-modular/TBoost.Conversion
-I/home/evansl/prog_dev/boost/boost-modular/enums
-I/home/evansl/prog_dev/clang/libcxx/sandbox/libs/composite_storage/include
-I/home/evansl/prog_dev/boost/sandbox/rw/sandbox/lje
-I/home/evansl/prog_dev/boost/boost-releases/ro/boost_1_56_0
-DTYPE_AT_IMPL=0 -ftemplate-depth=324 texpressions.cpp -MMD -o
/tmp/build/clangxx3_5_bin/clang/libcxx/sandbox/libs/gram_stk/sandbox/texpressions.o
I'm getting the error message:
In file included from texpressions.cpp:1:
./texpressions.hpp:1076:36: fatal error: recursive template
instantiation exceeded maximum depth of 324
boost::trace_scope trace_scope(__FUNCTION__);
^
./texpressions.hpp:991:19: note: in instantiation of function template
specialization
'texpressions<my_symbols>::definitions<my_attrs,
composite_storage::type_sequence<texpressions<my_symbols>::def_as<0, 1,
texpressions<my_symbols>::expr_prefx<op_assoc<0, 0>,
texpressions<my_symbols>::expr_prefx<texpressions<my_symbols>::op_symb<0, 0>>,
texpressions<my_symbols>::expr_prefx<op_assoc<1, 0>,
texpressions<my_symbols>::expr_prefx<texpressions<my_symbols>::op_symb<0, 1>>,
texpressions<my_symbols>::expr_prefx<texpressions<my_symbols>::op_symb<1, 0>>
> > > > >::read_fold_from<0,
iter_range<my_symbols<0>::syms,
inp_out_type<my_symbols<0>::syms>::out_type>, def_now_t,
texpressions<my_symbols>::expr_prefx<texpressions<my_symbols>::op_symb<0, 0>>,
texpressions<my_symbols>::expr_prefx<op_assoc<1, 0>,
texpressions<my_symbols>::expr_prefx<texpressions<my_symbols>::op_symb<0, 1>>,
texpressions<my_symbols>::expr_prefx<texpressions<my_symbols>::op_symb<1, 0>>
> >' requested here
read_fold_from
^
Part of the code is:
template
< typename LiterlStream
, vars AnVarble
, typename DefNow
>
bool
#define READ_FROM_VAR_NOINLINE
#ifdef READ_FROM_VAR_NOINLINE
__attribute__((noinline))
#endif
read_from
( LiterlStream& is
, DefNow& def_now_inp
, expr_prefx
< op_symb
< symb_kinds::varble_kind
, AnVarble
>
>const& a_expr
)const
//#define READ_FROM_VAR_DEF_OUT_CLASS
#ifdef READ_FROM_VAR_DEF_OUT_CLASS
;
#else
{
boost::trace_scope trace_scope(__FUNCTION__);
std::cout<<"read_from(op_varble<"<<AnVarble<<">)"<<std::endl;
bool
result=read_def_from(is,def_now_inp,this->get_def<AnVarble>());
return result;
}
#endif
The error does not occur when defined(READ_FROM_VAR_DEF_OUT_CLASS).
I was thinking that maybe unrestrained inlining of the code
would be causing the problem, but, as seen from the above
code, even with the __attribute__((noinline)), the error message
occurs.
I'd appreciate any suggestions on how to avoid this fatal error
message about excessive template instantiation.
-regards,
Larry
More information about the cfe-users
mailing list