https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82833
Bug ID: 82833 Summary: [concepts] Out-of-line definition of nested class template errors with constraint (ICE) Product: gcc Version: 7.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: kjcamann.lists at gmail dot com Target Milestone: --- The behavior is different between gcc 7.1 and my latest gcc 8 build. gcc 7 produces an error message, whereas in gcc 8 (built from a1920064e2, around 11/3/2017) it is an ICE. Here is the code: ``` #include <functional> // Check that std::invoke(<any constexpr callable>, <instance of t>) // yields an `M` type template <typename T, auto A, typename M> concept bool CallYieldsType = requires(T t) { { std::invoke(A, t) } -> M; }; template <typename T> struct S { struct Z; // Declared here, but defined out of line. If defined here, this works. template <auto A> requires CallYieldsType<T, A, Z> struct N; }; template <typename T> template <auto A> requires CallYieldsType<T, A, typename S<T>::Z> struct S<T>::N { Z &f(T t) { return std::invoke(A, t); } }; ``` This error is related to the combination of concept checking and out-of-line definition, because if I remove either one (by removing the requires clause, *or* by defining S<T>::N inline) it works fine. gcc 7.1 says: test3.cpp:29:16: error: ‘S<T>::N<A>’ does not match any declaration struct S<T>::N { gcc 8 says: test3.cpp:29:16: error: ‘S<T>::N<A>’ does not match any declaration struct S<T>::N { ^ test3.cpp:29:16: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in cp_parser_class_specifier_1, at cp/parser.c:22492 0x6868c8 tree_class_check_failed(tree_node const*, tree_code_class, char const*, int, char const*) ../.././gcc/tree.c:9146 0x85085c tree_class_check(tree_node*, tree_code_class, char const*, int, char const*) ../.././gcc/tree.h:3211 0x85085c cp_parser_class_specifier_1 ../.././gcc/cp/parser.c:22492 0x850ae1 cp_parser_class_specifier ../.././gcc/cp/parser.c:22754 0x850ae1 cp_parser_type_specifier ../.././gcc/cp/parser.c:16818 0x85fc31 cp_parser_decl_specifier_seq ../.././gcc/cp/parser.c:13684 0x864d25 cp_parser_single_declaration ../.././gcc/cp/parser.c:27131 0x8650bc cp_parser_template_declaration_after_parameters ../.././gcc/cp/parser.c:26823 0x865b4c cp_parser_explicit_template_declaration ../.././gcc/cp/parser.c:27060 0x865b4c cp_parser_template_declaration_after_export ../.././gcc/cp/parser.c:27079 0x865075 cp_parser_template_declaration_after_parameters ../.././gcc/cp/parser.c:26812 0x865b4c cp_parser_explicit_template_declaration ../.././gcc/cp/parser.c:27060 0x865b4c cp_parser_template_declaration_after_export ../.././gcc/cp/parser.c:27079 0x86bd79 cp_parser_declaration ../.././gcc/cp/parser.c:12788 0x86c0b1 cp_parser_declaration_seq_opt ../.././gcc/cp/parser.c:12715 0x86c3bf cp_parser_translation_unit ../.././gcc/cp/parser.c:4502 0x86c3bf c_parse_file() ../.././gcc/cp/parser.c:39021 0x9adff6 c_common_parse_file() ../.././gcc/c-family/c-opts.c:1124 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions.