https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70466
Bug ID: 70466 Summary: ICE on invalid code on x86_64-linux-gnu in tree check: expected constructor, have parm_decl in convert_like_real, at cp/call.c:6371 Product: gcc Version: 6.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 causes an ICE when compiled with the current GCC trunk on x86_64-linux-gnu in both 32-bit and 64-bit modes. This is a regression from 5.3.x. $ 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/6.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 6.0.0 20160330 (experimental) [trunk revision 234546] (GCC) $ $ g++-trunk small.cpp small.cpp:1:21: error: conflicting declaration ‘class T’ template < class T, class T > ^~~~~ small.cpp:1:12: note: previous declaration as ‘class T’ template < class T, class T > ^~~~~ small.cpp:5:19: error: expected ‘)’ before ‘::’ token explicit A (T (S::*f) ()) {} ^~ small.cpp:5:19: error: expected ‘)’ before ‘::’ token small.cpp:5:18: error: expected ‘;’ at end of member declaration explicit A (T (S::*f) ()) {} ^ small.cpp:5:21: error: expected id-expression before ‘*’ token explicit A (T (S::*f) ()) {} ^ small.cpp: In instantiation of ‘A<T, S> foo(T (S::*)()) [with T = void; S = B]’: small.cpp:23:15: required from here small.cpp:11:10: internal compiler error: tree check: expected constructor, have parm_decl in convert_like_real, at cp/call.c:6371 return A < T, S > (f); ^~~~~~~~~~~~~~ 0xfe3e6c tree_check_failed(tree_node const*, char const*, int, char const*, ...) ../../gcc-source-trunk/gcc/tree.c:9643 0x615e30 tree_check ../../gcc-source-trunk/gcc/tree.h:3006 0x615e30 convert_like_real ../../gcc-source-trunk/gcc/cp/call.c:6371 0x614608 convert_like_real ../../gcc-source-trunk/gcc/cp/call.c:6539 0x61187f build_over_call ../../gcc-source-trunk/gcc/cp/call.c:7496 0x61e035 build_new_method_call_1 ../../gcc-source-trunk/gcc/cp/call.c:8419 0x61e035 build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, tree_node*, int, tree_node**, int) ../../gcc-source-trunk/gcc/cp/call.c:8489 0x61efd5 build_special_member_call(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, tree_node*, int, int) ../../gcc-source-trunk/gcc/cp/call.c:8026 0x621a4b perform_direct_initialization_if_possible(tree_node*, tree_node*, bool, int) ../../gcc-source-trunk/gcc/cp/call.c:9691 0x783797 build_static_cast_1 ../../gcc-source-trunk/gcc/cp/typeck.c:6724 0x784a57 cp_build_c_cast(tree_node*, tree_node*, int) ../../gcc-source-trunk/gcc/cp/typeck.c:7423 0x6d248a build_functional_cast(tree_node*, tree_node*, int) ../../gcc-source-trunk/gcc/cp/typeck2.c:2011 0x68c3b3 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../gcc-source-trunk/gcc/cp/pt.c:16083 0x67db0f tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc-source-trunk/gcc/cp/pt.c:15802 0x67e18b tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc-source-trunk/gcc/cp/pt.c:15114 0x67f050 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc-source-trunk/gcc/cp/pt.c:15290 0x67b6a8 instantiate_decl(tree_node*, int, bool) ../../gcc-source-trunk/gcc/cp/pt.c:22013 0x6c7a52 instantiate_pending_templates(int) ../../gcc-source-trunk/gcc/cp/pt.c:22132 0x70a3d7 c_parse_final_cleanups() ../../gcc-source-trunk/gcc/cp/decl2.c:4599 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, class T > // should be: template < class T, class S > class A { public: explicit A (T (S::*f) ()) {} }; template < class T, class S > A < T, S > foo (T (S::*f) ()) { return A < T, S > (f); } class B { public: void bar () {} }; int main () { foo (&B::bar); return 0; }