[Bug c++/126414] New: ICE after adding explicit `this` on a hidden friend

hanicka at hanicka dot net via Gcc-bugs <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126414

            Bug ID: 126414
           Summary: ICE after adding explicit `this` on a hidden friend
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hanicka at hanicka dot net
  Target Milestone: ---

Following code crashes GCC starting from 14 (first version with explicit `this`
support) to current latest daily build of GCC (at CE).

```c++
struct foo {
        friend void bar(this foo) { }
};

void call_me_baby() {
    foo f;
        bar(f); // crash here, because of `this` on the friend void bar(this
foo)
}
```

in commit `7149f5ebd52eee6ad29a06f6d46c4142d0eccf46` it crashes with following
backtrace:

```
0x2b51d78 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x2b469bb internal_error(char const*, ...)
        ???:0
0xb760b7 build_new_function_call(tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
        ???:0
0xe3585d finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
        ???:0
0xd92323 c_parse_file()
        ???:0
0xf25519 c_common_parse_file()
        ???:0
/cefs/a9/a9f609f4e529fe4607279f68_gcc-trunk-20260726/bin/../libexec/gcc/x86_64-linux-gnu/17.0.0/cc1plus
-quiet -imultiarch x86_64-linux-gnu -iprefix
/cefs/a9/a9f609f4e529fe4607279f68_gcc-trunk-20260726/bin/../lib/gcc/x86_64-linux-gnu/17.0.0/
-D_GNU_SOURCE <source> -quiet -dumpdir /app/ -dumpbase output.cpp -dumpbase-ext
.cpp -masm=intel -mtune=generic -march=x86-64 -g -O3 -std=c++23
-fdiagnostics-color=always -fno-verbose-asm -freport-bug -o /app/output.s
```

https://compiler-explorer.com/z/r698dsMfh
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.