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

            Bug ID: 123554
           Summary: C++23 explicit object parameter: invalid second this
                    parameter causes ICE in grokdeclarator
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: attackerj1113 at gmail dot com
  Target Milestone: ---

The following invalid code causes ICE on x86-64 gcc only on trunk:


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
struct Foo {
    template<class Self>
    void Bar(this Self&& self, this Foo&& self)  {}
};

void fn() {
  Foo{}.Bar();
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Please check  https://godbolt.org/z/qEaKqbr37

GCC ICEs when handling an invalid C++23 explicit object-parameter declaration:
a member function with two this parameters and a name conflict should only
produce diagnostics, but instead triggers an internal error in grokdeclarator
when it encounters an error_mark node.

Compiler Output:

<source>:3:43: error: conflicting declaration 'Foo&& self'
    3 |     void Bar(this Self&& self, this Foo&& self)  {}
      |                                ~~~~~~~~~~~^~~~
<source>:3:26: note: previous declaration as 'Self&& self'
    3 |     void Bar(this Self&& self, this Foo&& self)  {}
      |              ~~~~~~~~~~~~^~~~
<source>:3:47: internal compiler error: tree check: expected tree that contains
'decl minimal' structure, have 'error_mark' in grokdeclarator, at
cp/decl.cc:15032
    3 |     void Bar(this Self&& self, this Foo&& self)  {}
      |                                               ^
0x2926688 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x291b44b internal_error(char const*, ...)
        ???:0
0xa1b84e tree_contains_struct_check_failed(tree_node const*,
tree_node_structure_enum, char const*, int, char const*)
        ???:0
0xc2067c grokmethod(cp_decl_specifier_seq*, cp_declarator const*, tree_node*)
        ???:0
0xd57563 c_parse_file()
        ???:0
0xec8ee9 c_common_parse_file()
        ???:0
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.
Compiler returned: 1
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1

Reply via email to