Following code: struct X { void f(); }; struct Y { void f(); }; template <typename Base> struct A : Base, X { virtual void foo() { f(); } }; int main() { A<Y> t; } gives error message: j_test.cpp: In member function `void A<Base>::foo() [with Base = Y]': j_test.cpp:21: instantiated from here j_test.cpp:16: error: request for member `f' is ambiguous j_test.cpp:4: error: candidates are: void X::f() j_test.cpp:9: error: void Y::f() = Y]': Even though the dependent base should not be considered. This seems to happen only when foo is virtual and f is found from non-dependent base. Using: Reading specs from /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.1/specs Configured with: ../gcc/configure --enable-languages=c++,c,f77 --enable-threads=posix Thread model: posix gcc version 3.4.1 20040501 (prerelease)
I think this is a dup of bug 5660.
Confirmed. BTW, even though the last line of the error message in the original report seems mangled, this must have been a copy-pasto on behalf of the reporter, since I can't reproduce that part. W.
Yes, the error message was my fault.. had some problems pasting and pasted it twice, seems i was not careful enough to correct it.
And this looks related to PR 2922 also.
*** Bug 30144 has been marked as a duplicate of this bug. ***
*** Bug 39541 has been marked as a duplicate of this bug. ***
Still happens with gcc4.5.1.
Still present in 4.7.1: tesarik@azariah:~/src/research/c++> g++ -Wall -c -o pr15272.o pr15272.cc pr15272.cc: In instantiation of ‘void A<Base>::foo() [with Base = Y]’: pr15272.cc:22:1: required from here pr15272.cc:15:5: error: request for member ‘f’ is ambiguous pr15272.cc:3:10: error: candidates are: void X::f() pr15272.cc:8:10: error: void Y::f() tesarik@azariah:~/src/research/c++> g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/i586-suse-linux/4.7/lto-wrapper Target: i586-suse-linux Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --libexecdir=/usr/lib --enable-languages=c,c++,objc,fortran,obj-c++,java,ada --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.7 --enable-ssp --disable-libssp --disable-libitm --disable-plugin --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --disable-libgcj --disable-libmudflap --with-slibdir=/lib --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-version-specific-runtime-libs --enable-linker-build-id --program-suffix=-4.7 --enable-linux-futex --without-system-libunwind --with-arch-32=i586 --with-tune=generic --build=i586-suse-linux Thread model: posix gcc version 4.7.1 20120723 [gcc-4_7-branch revision 189773] (SUSE Linux)
Jason, we apparently still do lookup in dependent bases inside virtual functions.
It seems that when in instantiate_class_template_1 the base classes are tsubst-ed the information about BINFO_DEPENDENT_BASE_P gets lost.
Paolo, did you manage to make any progress on this?
Nope, sorry, I told Jason a few days ago.
Reconfirming as still present in 6.0 (and all prior versions): $ cat v.c && /home/msebor/build/gcc-trunk-svn/gcc/xgcc -B/home/msebor/build/gcc-trunk-svn/gcc -S -Wall -Wextra -Wpedantic -xc++ v.c struct X { void f (); }; struct Y { void f (); }; template <class T> struct A: T, X { void foo () { f (); } }; template struct A<Y>; v.c: In instantiation of ‘void A<T>::foo() [with T = Y]’: v.c:11:17: required from here v.c:7:5: error: request for member ‘f’ is ambiguous f (); ^ v.c:1:17: note: candidates are: void X::f() struct X { void f (); }; ^ v.c:2:17: note: void Y::f() struct Y { void f (); }; ^
No change in 7.0. Lowering Importance to P3.
Nathan, do you want to fix this as part of your lookup overhaul? The problem is that tsubst_baselink does a new lookup rather than preserve the old lookup set. It would also be good to add a warning for the case when that makes a difference.
sure thing
Author: nathan Date: Wed Dec 13 12:40:45 2017 New Revision: 255605 URL: https://gcc.gnu.org/viewcvs?rev=255605&root=gcc&view=rev Log: [PR C++/15272] lookups with ambiguating dependent base https://gcc.gnu.org/ml/gcc-patches/2017-12/msg00766.html PR c++/15272 * pt.c (tsubst_baselink): Don't repeat the lookup for non-dependent baselinks. PR c++/15272 * g++.dg/template/pr71826.C: Adjust for 15272 fix. Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/pt.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/template/pr71826.C
Fixed r255605.