[Bug c++/106179] [13 Regression] Rejected code since r13-1390-g07ac550393d00fca

jason at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jul 5 21:27:38 GMT 2022


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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> ---
The P1787 scope/lookup overhaul clarified that Mat_ in .operator Mat_ is looked
up in the same way as a name mentioned immediately after the ., and since
commaInitializer has dependent type _Tp, we don't know whether "Mat_" is
supposed to name a member type of _Tp or the Mat_ in the enclosing scope, so we
don't know if it's a template.  Except that it has to be a type, so it has to
be a template.  So yes, it should work.

As should this:

template <class T> struct Mat {
  Mat();
};

//template <typename> struct Mat_;                                              
template <typename _Tp> Mat<_Tp>::Mat() {
  auto commaInitializer = _Tp().operator Mat_<_Tp>();
}

struct A
{
  template <class T> struct Mat_ { };
  template <class T> operator Mat_<T>();
};

Mat<A> m;


More information about the Gcc-bugs mailing list