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

            Bug ID: 97340
           Summary: Spurious rejection of member variable template of
                    reference type
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: herring at lanl dot gov
  Target Milestone: ---

In many recent versions of GCC, the following valid code

  struct A {
    template<class>
    static constexpr const int &x=0;
  };
  template<class T=void>
  struct B {
    static constexpr int y=A::template x<int>;
  };
  template struct B<>;

produces

error: ''indirect_ref' not supported by dump_decl<declaration error>' is not a
template [-fpermissive]
    7 |   static constexpr int y=A::template x<int>;
      |                          ~~~~~~~~~~~~^~~~~~

The 'template' after '::' here is unnecessary; removing it avoids the error,
but the error also appears if A is a class template (so that it's necessary to
write "A<T>::template x<int>").  Making A::x not be a reference also avoids the
error, as does referring to it from a non-templated context.

Reply via email to