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

            Bug ID: 101680
           Summary: spurious error: use of ‘this’ in a constant expression
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mu11 at yahoo dot com
  Target Milestone: ---

g++ issues a spurious error for the following test case:

$ cat t.cpp
template<auto & TASK, int, typename... ARGS> auto f1(ARGS &&...);

template<class T, int>
struct F { };

template<class T, class C>
struct K { };

template<typename T>
struct N {
  using i = typename T::i;
  struct M { };
  static void S(typename F<K<M, i>, 1>::template A<2> m) { }
  void f2() {
#ifdef BUG
    f1<N<T>::S, int>(this->t);
#else
    f1<S, int>(this->t);
#endif
  }
};

% g++ -c -std=c++17 t.cpp
% 

% g++ -c -DBUG -std=c++17 t.cpp
t.cpp: In member function ‘void N<T>::f2()’:
t.cpp:16:14: error: use of ‘this’ in a constant expression
   16 |     f1<N<T>::S, int>(this->t);
      |              ^

Reply via email to