https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86558
Bug ID: 86558
Summary: ICE on template code
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: zhonghao at pku dot org.cn
Target Milestone: ---
The code is as follow:
template <bool> struct VI {};
template <typename T>
struct IP
{
static const bool r = IP<T>::r;
};
template <typename T> struct V
{
VI<IP<T>::r> vi;
};
struct X;
struct Y
{
V<X> v;
};
g++ produces the following messages:
code0.cpp: In instantiation of 'const bool IP<X>::r':
code0.cpp:5:20: recursively required from 'const bool IP<X>::r'
code0.cpp:5:20: required from 'const bool IP<X>::r'
code0.cpp:9:15: required from 'struct V<X>'
code0.cpp:14:7: required from here
code0.cpp:5:20: fatal error: template instantiation depth exceeds maximum of
900 (use -ftemplate-depth= to increase the maximum)
static const bool r = IP<T>::r;
^
compilation terminated.
I increased the depth: g++ -ftemplate-depth=100000 code0.cpp
This time, I got an ICE:
g++: internal compiler error: Segmentation fault signal terminated program
cc1plus
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
root@haozhong-Precision-Tower-7910:/home/haozhong/project/approach/otherreport/g
cc/tmp/gcc_50436# g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/9.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc9.0/configure --enable-languages=c,c++
--disable-multilib
Thread model: posix
gcc version 9.0.0 20180715 (experimental) (GCC)