[Bug c++/95158] [10/11 Regression] Templates + Diamond Inheritance + Final = Pure Virtual Function Call
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jun 4 19:13:39 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95158
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:
https://gcc.gnu.org/g:e244b0acf3111c95bb1559e7610f84740b90589f
commit r10-8242-ge244b0acf3111c95bb1559e7610f84740b90589f
Author: Jason Merrill <jason@redhat.com>
Date: Wed Jun 3 23:50:06 2020 -0400
c++: Fix FE devirt with diamond inheritance [PR95158]
This started breaking in GCC 8 because of the fix for PR15272; after that
change, we (correctly) remember the lookup from template parsing time that
found Base::foo through the non-dependent MiddleB base, and so we overlook
the overrider in MiddleA. But given that, the devirtualization condition
from the fix for PR59031 is insufficient; we know that d has to be a
Derived, and we found Base::foo in Base, but forcing a non-virtual call
gets the wrong function.
Fixed by removing the PR59031 code that the PR67184 patch moved to
build_over_call, and instead looking up the overrider in BINFO_VIRTUALS.
gcc/cp/ChangeLog:
PR c++/95158
* class.c (lookup_vfn_in_binfo): New.
* call.c (build_over_call): Use it.
* cp-tree.h (resolves_to_fixed_type_p): Add default argument.
(lookup_vfn_in_binfo): Declare.
gcc/testsuite/ChangeLog:
PR c++/95158
* g++.dg/template/virtual5.C: New test.
More information about the Gcc-bugs
mailing list