https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91706
--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jason Merrill <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:f07edb5d7f3e77218ec846a9382f7c1d23e67b71 commit r12-1272-gf07edb5d7f3e77218ec846a9382f7c1d23e67b71 Author: Jason Merrill <ja...@redhat.com> Date: Fri Apr 16 11:13:40 2021 -0400 c++: alias with same name as base fn [PR91706] This is a bit complex. Looking up c<T> in the definition of D::c finds C::c, OK. Looking up c in the definition of E finds D::c, OK. Since the alias is not dependent, we strip it from the template argument, leaving using E = A<decltype(c<T>())>; where 'c' still refers to C::c. But instantiating E looks up 'c' again and finds D::c, which isn't a function, and sadness ensues. I think the bug here is looking up 'c' in D at instantiation time; the declaration we found before is not dependent. This seems to happen because baselink_for_fns gets BASELINK_BINFO wrong; it is supposed to be the base where lookup found the functions, C in this case. gcc/cp/ChangeLog: PR c++/91706 * semantics.c (baselink_for_fns): Fix BASELINK_BINFO. gcc/testsuite/ChangeLog: PR c++/91706 * g++.dg/template/lookup17.C: New test.