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

            Bug ID: 126520
           Summary: [c++26] [reflection] reflect-expression of a member
                    function template specialization fails when the
                    enclosing scope is dependent
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 121539739 at qq dot com
  Target Milestone: ---

With -std=c++26 -freflection, applying the reflect operator `^^` to a
template-id that names a member function template specialization is
rejected at instantiation time when (and only when) the nested-name-
specifier is dependent.

Minimal testcase:

```cpp
template <class> struct s {
    template <int> void bar() {}
};

template <class T>
void f() { constexpr auto r = ^^s<T>::template bar<0>; }

template void f<int>();
```

Command line:

    g++ -std=c++26 -freflection -c repro.cpp

Actual output:

    repro.cpp: In instantiation of 'void f() [with T = int]':
    repro.cpp:8:22:   required from here
        8 | template void f<int>();
          |                      ^
    repro.cpp:6:48: error: 'bar' was not declared in this scope
        6 | void f() { constexpr auto r = ^^s<T>::template bar<0>; }
          |                                                ^~~~~~

Expected: accepted. The same construct written with a non-dependent
scope compiles fine:

```cpp
constexpr auto ok = ^^s<int>::bar<0>;   // OK
```

Reply via email to