https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117351

            Bug ID: 117351
           Summary: ICE while reporting invalid template error
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ak at gcc dot gnu.org
  Target Milestone: ---

While trying to reduce another problem I hit this: 

foo.cc:

template <_Lp> struct __shared_ptr_access {
  template <typename>
  using __esft_base_t decltype(__enable_shared_from_this_base());
  template <typename _Yp> __esft_base_t<_Yp>


cc1plus foo.cc
gu.cc:1:11: error: ‘_Lp’ has not been declared
    1 | template <_Lp> struct __shared_ptr_access {
      |           ^~~
gu.cc:3:23: error: expected ‘=’ before ‘decltype’ [-Wtemplate-body]
    3 |   using __esft_base_t decltype(__enable_shared_from_this_base());
      |                       ^~~~~~~~
gu.cc:3:32: error: there are no arguments to ‘__enable_shared_from_this_base’
that depend on a template parameter, so a declaration of
‘__enable_shared_from_this_base’ must be available [-Wtemplate-body]
    3 |   using __esft_base_t decltype(__enable_shared_from_this_base());
      |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gu.cc:3:32: note: (if you use ‘-fpermissive’, G++ will accept your code, but
allowing the use of an undeclared name is deprecated)
gu.cc:3:32: error: there are no arguments to ‘__enable_shared_from_this_base’
that depend on a template parameter, so a declaration of
‘__enable_shared_from_this_base’ must be available [-Wtemplate-body]
gu.cc: In substitution of ‘template<<typeprefixerror><anonymous> >
template<class> using __shared_ptr_access<<anonymous> >::__esft_base_t =
decltype (__enable_shared_from_this_base()) [with <template-parameter-2-1> =
_Yp; <typeprefixerror><anonymous> = <expression error>]’:
gu.cc:4:44:   required from here
    4 |   template <typename _Yp> __esft_base_t<_Yp>
      |                                            ^
gu.cc:3:62: error: ‘__enable_shared_from_this_base’ was not declared in this
scope
    3 |   using __esft_base_t decltype(__enable_shared_from_this_base());
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
gu.cc:4:44: internal compiler error: Segmentation fault
    4 |   template <typename _Yp> __esft_base_t<_Yp>
      |                                            ^
0x27adb7f internal_error(char const*, ...)
        ../../gcc/gcc/diagnostic-global-context.cc:518
0x135ed66 crash_signal
        ../../gcc/gcc/toplev.cc:323
0x9fe1b7 tree_class_check(tree_node*, tree_code_class, char const*, int, char
const*)
        ../../gcc/gcc/tree.h:3797
0x9fe1b7 pop_nested_class()
        ../../gcc/gcc/cp/class.cc:8636
0xc322d9 instantiate_template(tree_node*, tree_node*, int)
        ../../gcc/gcc/cp/pt.cc:22304
0xc33c8a instantiate_alias_template(tree_node*, tree_node*, int) [clone
.part.0] [clone .lto_priv.0]
        ../../gcc/gcc/cp/pt.cc:22400
0xc07640 instantiate_alias_template
        ../../gcc/gcc/cp/pt.cc:22378
0xc07640 lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int)
        ../../gcc/gcc/cp/pt.cc:10177
0xc4c037 finish_template_type(tree_node*, tree_node*, int)
        ../../gcc/gcc/cp/semantics.cc:4144
0xb92ced cp_parser_template_id
        ../../gcc/gcc/cp/parser.cc:19301
0xb92f65 cp_parser_class_name
        ../../gcc/gcc/cp/parser.cc:26973
0xb97d12 cp_parser_qualifying_entity
        ../../gcc/gcc/cp/parser.cc:7438
0xb97d12 cp_parser_nested_name_specifier_opt
        ../../gcc/gcc/cp/parser.cc:7124
0xbacdb4 cp_parser_constructor_declarator_p
        ../../gcc/gcc/cp/parser.cc:32800
0xbacdb4 cp_parser_decl_specifier_seq
        ../../gcc/gcc/cp/parser.cc:16872
0xbb7068 cp_parser_single_declaration
        ../../gcc/gcc/cp/parser.cc:33467
0xbb7662 cp_parser_template_declaration_after_parameters
        ../../gcc/gcc/cp/parser.cc:33228
0xbb7662 cp_parser_explicit_template_declaration
        ../../gcc/gcc/cp/parser.cc:33398
0xb86e10 cp_parser_member_specification_opt
        ../../gcc/gcc/cp/parser.cc:28187
0xb86e10 cp_parser_class_specifier
        ../../gcc/gcc/cp/parser.cc:27166
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Reply via email to