[Bug c++/126520] New: [c++26] [reflection] reflect-expression of a member function template specialization fails when the enclosing scope is dependent

121539739 at qq dot com via Gcc-bugs <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
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
```
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.