https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71820
Bug ID: 71820 Summary: ICE on valid C++ code: in arg_assoc_type, at cp/name-lookup.c:5583 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++ 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 appears to affect all versions since at least as early as 4.4.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/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 20160707 (experimental) [trunk revision 238117] (GCC) $ $ clang++-3.8 -c small.cpp $ $ g++-trunk -c small.cpp small.cpp: In substitution of ‘template<class T> void f1(__typeof__ (f(f0<T>))) [with T = int]’: small.cpp:13:16: required from here small.cpp:8:24: internal compiler error: in arg_assoc_type, at cp/name-lookup.c:5583 void f1 (__typeof__ (f (f0 < T >))) {} ~~~^~~~~~~~~~~ 0x8778d2 arg_assoc_type ../../gcc-source-trunk/gcc/cp/name-lookup.c:5583 0x877866 arg_assoc_args ../../gcc-source-trunk/gcc/cp/name-lookup.c:5594 0x877866 arg_assoc_type ../../gcc-source-trunk/gcc/cp/name-lookup.c:5566 0x8770cd arg_assoc ../../gcc-source-trunk/gcc/cp/name-lookup.c:5665 0x877298 arg_assoc ../../gcc-source-trunk/gcc/cp/name-lookup.c:5653 0x87c6d1 arg_assoc_args_vec ../../gcc-source-trunk/gcc/cp/name-lookup.c:5609 0x87c6d1 lookup_arg_dependent_1 ../../gcc-source-trunk/gcc/cp/name-lookup.c:5714 0x87c6d1 lookup_arg_dependent(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>*) ../../gcc-source-trunk/gcc/cp/name-lookup.c:5742 0x815644 perform_koenig_lookup(cp_expr, vec<tree_node*, va_gc, vl_embed>*, int) ../../gcc-source-trunk/gcc/cp/semantics.c:2244 0x6e542e tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../gcc-source-trunk/gcc/cp/pt.c:16590 0x6d6c2f tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc-source-trunk/gcc/cp/pt.c:15868 0x6ea34a tsubst(tree_node*, tree_node*, int, tree_node*) ../../gcc-source-trunk/gcc/cp/pt.c:13569 0x6f8752 tsubst_arg_types ../../gcc-source-trunk/gcc/cp/pt.c:12559 0x6f8b4c tsubst_function_type ../../gcc-source-trunk/gcc/cp/pt.c:12694 0x6e9fb7 tsubst(tree_node*, tree_node*, int, tree_node*) ../../gcc-source-trunk/gcc/cp/pt.c:13416 0x713b1d fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node* const*, unsigned int, tree_node*, unification_kind_t, int, bool, bool) ../../gcc-source-trunk/gcc/cp/pt.c:17795 0x67468b add_template_candidate_real ../../gcc-source-trunk/gcc/cp/call.c:3110 0x6753bc add_template_candidate ../../gcc-source-trunk/gcc/cp/call.c:3188 0x6753bc add_candidates ../../gcc-source-trunk/gcc/cp/call.c:5361 0x6779b9 perform_overload_resolution ../../gcc-source-trunk/gcc/cp/call.c:4045 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. $ ------------------------------------------- int f (int); int f (void (*) (int, int)); template < typename T > void f0 (T x, __typeof__ (f (x)) y) {} template < typename T > void f1 (__typeof__ (f (f0 < T >))) {} int main () { f0 < int > (0, 0); f1 < int > (0); return 0; }