diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index 14c6037729f..85fe9b5ab85 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -9244,8 +9244,8 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) } else { - tree binfo = TYPE_BINFO (TREE_TYPE (first_arg)); - callee = build_baselink (binfo, binfo, fn, NULL_TREE); + callee = build_baselink (cand->conversion_path, cand->access_path, + fn, NULL_TREE); callee = build_min (COMPONENT_REF, TREE_TYPE (fn), first_arg, callee, NULL_TREE); } diff --git a/gcc/testsuite/g++.dg/template/non-dependent24.C b/gcc/testsuite/g++.dg/template/non-dependent24.C new file mode 100644 index 00000000000..0ddc75c78ee --- /dev/null +++ b/gcc/testsuite/g++.dg/template/non-dependent24.C @@ -0,0 +1,19 @@ +// PR c++/105758 + +struct A { + void foo(int); +}; + +template +struct Z : A { + static Z *z; + void bar(); +}; + +template +Z *Z::z; + +template +void Z::bar() { + z->foo(0); +}