https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84434
Bug ID: 84434 Summary: [8 Regression] internal compiler error: tree check: expected var_decl or field_decl or function_decl or type_decl or template_decl, have using_decl in build_deduction_guide, at cp/pt.c:25636 Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mpolacek at gcc dot gnu.org Target Milestone: --- namespace std { template <typename _Tp> using decay_t = _Tp; template <typename> class optional {}; } // namespace std class RiskAnalysis { struct Context; void RunAnalysis(std::optional<Context>) noexcept; }; namespace ext { namespace detail::scope_guard { template <typename Fn> class A { Fn m_fn; public: template <typename Fn_> A(Fn_ p1) : m_fn(p1) {} }; template <typename... Params> class B { using callback_type = scope_guard::A<Params...>; callback_type callback; public: template <typename... Params_> B(Params_... p1) : callback(p1...) {} }; template <typename T> struct C { using type = T; }; template <typename T> using unwrap_decay_t = typename C<std::decay_t<T>>::type; } // namespace detail::scope_guard template <typename... Params> struct scope_guard : detail::scope_guard::B<Params...> { using base_type = detail::scope_guard::B<Params...>; using base_type::base_type; ~scope_guard(); }; template <typename... Params> scope_guard(Params...) ->scope_guard<detail::scope_guard::unwrap_decay_t<Params>...>; } // namespace ext void RiskAnalysis::RunAnalysis(std::optional<Context>) noexcept { ext::scope_guard([] {}); } $ ./cc1plus -quiet bz.cc -std=c++17 bz.cc: In member function ‘void RiskAnalysis::RunAnalysis(std::optional<RiskAnalysis::Context>)’: bz.cc:40:25: internal compiler error: tree check: expected var_decl or field_decl or function_decl or type_decl or template_decl, have using_decl in build_deduction_guide, at cp/pt.c:25636 ext::scope_guard([] {}); ^ 0x15d5158 tree_check_failed(tree_node const*, char const*, int, char const*, ...) /home/marek/src/gcc/gcc/tree.c:9335 0x82674b tree_check5(tree_node*, char const*, int, char const*, tree_code, tree_code, tree_code, tree_code, tree_code) /home/marek/src/gcc/gcc/tree.h:3223 0xa71f40 build_deduction_guide /home/marek/src/gcc/gcc/cp/pt.c:25636 0xa74140 do_class_deduction /home/marek/src/gcc/gcc/cp/pt.c:25850 0xa74955 do_auto_deduction(tree_node*, tree_node*, tree_node*, int, auto_deduction_context, tree_node*, int) /home/marek/src/gcc/gcc/cp/pt.c:25978 0xb110d1 build_functional_cast(tree_node*, tree_node*, int) /home/marek/src/gcc/gcc/cp/typeck2.c:2088 0x9cefcb cp_parser_functional_cast /home/marek/src/gcc/gcc/cp/parser.c:27250 0x9a6287 cp_parser_postfix_expression /home/marek/src/gcc/gcc/cp/parser.c:6952 0x9a9b63 cp_parser_unary_expression /home/marek/src/gcc/gcc/cp/parser.c:8318 0x9aac7f cp_parser_cast_expression /home/marek/src/gcc/gcc/cp/parser.c:9086 0x9aad79 cp_parser_binary_expression /home/marek/src/gcc/gcc/cp/parser.c:9187 0x9abad7 cp_parser_assignment_expression /home/marek/src/gcc/gcc/cp/parser.c:9476 0x9abe74 cp_parser_expression /home/marek/src/gcc/gcc/cp/parser.c:9645 0x9aefee cp_parser_expression_statement /home/marek/src/gcc/gcc/cp/parser.c:11112 0x9ae8fb cp_parser_statement /home/marek/src/gcc/gcc/cp/parser.c:10916 0x9af64d cp_parser_statement_seq_opt /home/marek/src/gcc/gcc/cp/parser.c:11255 0x9af543 cp_parser_compound_statement /home/marek/src/gcc/gcc/cp/parser.c:11209 0x9c3eaa cp_parser_function_body /home/marek/src/gcc/gcc/cp/parser.c:21750 0x9c416d cp_parser_ctor_initializer_opt_and_function_body /home/marek/src/gcc/gcc/cp/parser.c:21787 0x9cdad1 cp_parser_function_definition_after_declarator /home/marek/src/gcc/gcc/cp/parser.c:26688 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.