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;