https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77522
Bug ID: 77522 Summary: ICE on invalid code C++14 code: in tsubst_decl, at cp/pt.c:12447 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: --- It affects 4.9.x and later, which have C++14 support. $ g++-trunk -c -std=c++14 small.cpp small.cpp: In instantiation of ‘f(T)::<lambda()> [with T = int]’: small.cpp:3:18: required from ‘struct f(T) [with T = int]::<lambda()>’ small.cpp:3:8: required from ‘void f(T) [with T = int]’ small.cpp:8:7: required from here small.cpp:3:24: error: use of ‘f(T) [with T = int]::<lambda()>::__a’ before deduction of ‘auto’ auto g = [&a = f] () {}; ^ small.cpp:3:24: error: use of ‘f(T) [with T = int]::<lambda()>::__a’ before deduction of ‘auto’ small.cpp:3:24: internal compiler error: in tsubst_decl, at cp/pt.c:12447 0x6fe7c6 tsubst_decl ../../gcc-source-trunk/gcc/cp/pt.c:12447 0x6f32de tsubst(tree_node*, tree_node*, int, tree_node*) ../../gcc-source-trunk/gcc/cp/pt.c:12907 0x6e07fa tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc-source-trunk/gcc/cp/pt.c:15284 0x6dfa43 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc-source-trunk/gcc/cp/pt.c:15419 0x6dd120 instantiate_decl(tree_node*, int, bool) ../../gcc-source-trunk/gcc/cp/pt.c:22159 0x7266b5 instantiate_class_template_1 ../../gcc-source-trunk/gcc/cp/pt.c:10346 0x7266b5 instantiate_class_template(tree_node*) ../../gcc-source-trunk/gcc/cp/pt.c:10416 0x7cbf13 complete_type(tree_node*) ../../gcc-source-trunk/gcc/cp/typeck.c:133 0x6eaf2c tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../gcc-source-trunk/gcc/cp/pt.c:17269 0x6df247 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc-source-trunk/gcc/cp/pt.c:15936 0x5df520 tsubst_init ../../gcc-source-trunk/gcc/cp/pt.c:13966 0x6e3144 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc-source-trunk/gcc/cp/pt.c:15334 0x6dec3b tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc-source-trunk/gcc/cp/pt.c:15228 0x6dfa43 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc-source-trunk/gcc/cp/pt.c:15419 0x6dd120 instantiate_decl(tree_node*, int, bool) ../../gcc-source-trunk/gcc/cp/pt.c:22159 0x72a5f2 instantiate_pending_templates(int) ../../gcc-source-trunk/gcc/cp/pt.c:22278 0x76f597 c_parse_final_cleanups() ../../gcc-source-trunk/gcc/cp/decl2.c:4617 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 < class T = int > void f (T) { auto g = [&a = f] () {}; } int main () { f (0); return 0; }