[Bug c++/93310] Incorrect constexpr virtual evaluation inside a constructor
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jun 4 19:13:44 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93310
--- Comment #3 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:6b45b400c51be06f2d0e37a7b461cbd4ce9fe37d
commit r10-8243-g6b45b400c51be06f2d0e37a7b461cbd4ce9fe37d
Author: Jason Merrill <jason@redhat.com>
Date: Wed Jun 3 23:50:50 2020 -0400
c++: Fix complex constexpr virtual cases [PR93310].
The code in constexpr for looking up the actual type of the object and then
getting the virtual function from there broke for both of these tests: for
16, it assumed incorrectly that the DECL_VINDEX would apply to the most
derived type's vtable; for 17, it failed to consider that during
construction the base subobject is treated as being of the base type.
Fixed by just doing constant evaluation of the expression that looks up the
function in the vtable. This means that a virtual call will involve
loading
the vptr, so we will reject some calls through non-constexpr variables that
we previously accepted, but this seems appropriate to me. None of our
testcases were affected.
gcc/cp/ChangeLog:
PR c++/93310
* constexpr.c (cxx_eval_constant_expression) [OBJ_TYPE_REF]:
Evaluate OBJ_TYPE_REF_EXPR.
gcc/testsuite/ChangeLog:
PR c++/93310
* g++.dg/cpp2a/constexpr-virtual16.C: New test.
* g++.dg/cpp2a/constexpr-virtual17.C: New test.
* g++.dg/cpp2a/constexpr-new12.C: Adjust diagnostic.
More information about the Gcc-bugs
mailing list