https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83529
--- Comment #8 from Jason Merrill <jason at gcc dot gnu.org> --- (In reply to Jason Merrill from comment #6) > (In reply to Nathan Sidwell from comment #5) > > template <typename T> int Foo (T); > > > > template <int> class TPL; > > > > template <int I> > > constexpr TPL<Foo (I)> Foo (); // #1 > > > > template <int I> > > constexpr TPL<Foo (I)> Foo (); // #2 > > > > What I think is happening is that the definition at #1 changes the overload > > set to which 'Foo' binds. Thus in #2 the 'Foo (I)' finds something > > different. I don't think we prune the overload set until later? > > Hmm, I think we shouldn't be binding Foo at all, it's a dependent name. As Nathan points out on IRC, it isn't a dependent name because I is not type-dependent. In that case, we ought to be able to resolve the overload to a particular candidate rather than keep the whole overload set around. For simplicity, perhaps only in the case of calling a non-member function.