https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71511
Bug ID: 71511 Summary: ICE on valid C++11 code (with decltype) on x86_64-linux-gnu: in cxx_incomplete_type_diagnostic, at cp/typeck2.c:567 Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: su at cs dot ucdavis.edu Target Milestone: --- The following C++11 code causes an ICE when compiled with the current GCC trunk on x86_64-linux-gnu in both 32-bit and 64-bit modes. It also affects at least 4.8.x and later. $ g++-trunk -v Using built-in specs. COLLECT_GCC=g++-trunk COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto --prefix=/usr/local/gcc-trunk --disable-bootstrap Thread model: posix gcc version 7.0.0 20160612 (experimental) [trunk revision 237336] (GCC) $ $ g++-trunk -std=c++11 -c small.cpp small.cpp:8:52: internal compiler error: in cxx_incomplete_type_diagnostic, at cp/typeck2.c:567 template < typename T > int decltype (A < T > ())::i = 100; ^ 0x726173 cxx_incomplete_type_diagnostic(unsigned int, tree_node const*, tree_node const*, diagnostic_t) ../../gcc-source-trunk/gcc/cp/typeck2.c:567 0x7be5b5 cxx_incomplete_type_diagnostic ../../gcc-source-trunk/gcc/cp/cp-tree.h:6740 0x7be5b5 complete_type_or_maybe_complain(tree_node*, tree_node*, int) ../../gcc-source-trunk/gcc/cp/typeck.c:151 0x6a715f grokdeclarator(cp_declarator const*, cp_decl_specifier_seq*, decl_context, int, tree_node**) ../../gcc-source-trunk/gcc/cp/decl.c:10564 0x6aa806 start_decl(cp_declarator const*, cp_decl_specifier_seq*, int, tree_node*, tree_node*, tree_node**) ../../gcc-source-trunk/gcc/cp/decl.c:4827 0x7aa4b2 cp_parser_init_declarator ../../gcc-source-trunk/gcc/cp/parser.c:18566 0x7ac051 cp_parser_single_declaration ../../gcc-source-trunk/gcc/cp/parser.c:25876 0x7ac18c cp_parser_template_declaration_after_parameters ../../gcc-source-trunk/gcc/cp/parser.c:25481 0x7acb98 cp_parser_explicit_template_declaration ../../gcc-source-trunk/gcc/cp/parser.c:25709 0x7acb98 cp_parser_template_declaration_after_export ../../gcc-source-trunk/gcc/cp/parser.c:25727 0x7b47e9 cp_parser_declaration ../../gcc-source-trunk/gcc/cp/parser.c:12092 0x7b31c4 cp_parser_declaration_seq_opt ../../gcc-source-trunk/gcc/cp/parser.c:12022 0x7b34f8 cp_parser_translation_unit ../../gcc-source-trunk/gcc/cp/parser.c:4324 0x7b34f8 c_parse_file() ../../gcc-source-trunk/gcc/cp/parser.c:37486 0x917072 c_common_parse_file() ../../gcc-source-trunk/gcc/c-family/c-opts.c:1064 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. $ ----------------------------------------------------- template < typename T > class A { static int i; }; //okay: template < typename T > int A <T>::i = 100; template < typename T > int decltype (A < T > ())::i = 100;