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

            Bug ID: 123977
           Summary: ICE on member function pointer in C++26
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nikolasklauser at berlin dot de
  Target Milestone: ---

```
typedef void *&R;
struct MemFun03 {
  R f(...) const volatile;
  void f();
};
template <class CallSig> struct TestCaseImp {
  static void run() { (CallSig(MemFun03::*)) &MemFun03::f; }
};
void test_derived_from_ref_wrap() {
  TestCaseImp<void *&(...) const volatile>::run;
}
```

compiled with `-std=c++26` causes GCC to crash with this message:

```
./gcc_reduce.cpp: In instantiation of 'static void TestCaseImp<CallSig>::run()
[with CallSig = void*&(...) const volatile]':
required from here
./gcc_reduce.cpp:10:48:   
   10 |   TestCaseImp<void *&(...) const volatile>::run;
      |                                                ^
./gcc_reduce.cpp:7:23: internal compiler error: canonical types differ for
identical types 'void*&(...) const volatile' and 'void*&(...) const volatile'
    7 |   static void run() { (CallSig(MemFun03::*)) &MemFun03::f; }
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0x55d179207c72 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x55d1791fb38d internal_error(char const*, ...)
        ???:0
0x55d1773d44a9 comptypes(tree_node*, tree_node*, int)
        ???:0
0x55d1773f65e1 build_functional_cast(unsigned long, tree_node*, tree_node*,
int)
        ???:0
0x55d17734254d instantiate_decl(tree_node*, bool, bool)
        ???:0
0x55d17734d433 instantiate_pending_templates(int)
        ???:0
0x55d1771855c7 c_parse_final_cleanups()
        ???:0
0x55d177483e51 c_common_parse_file()
        ???:0
/usr/libexec/gcc/x86_64-pc-linux-gnu/16/cc1plus -quiet -D_GNU_SOURCE
./gcc_reduce.cpp -quiet -dumpdir a- -dumpbase gcc_reduce.cpp -dumpbase-ext .cpp
-mtune=generic -march=x86-64 -mtls-dialect=gnu2 -w -std=c++26 -freport-bug
-foffload-options=-l_GCC_stdc++ -foffload-options=-l_GCC_m
-foffload-options=-fno-stack-protector -fcf-protection
-foffload-options=-fcf-protection=none -o /tmp/ccgvdORv.s
```

This has been reduced from a libc++ test case and is a GCC 16 regression.

Reply via email to