https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92695
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
To be precise, I meant something like:
--- gcc/cp/constexpr.c.jj 2019-11-27 10:03:37.916867165 +0100
+++ gcc/cp/constexpr.c 2019-11-27 16:55:17.475150697 +0100
@@ -1441,6 +1441,22 @@ cxx_bind_parameters_in_call (const const
arg = adjust_temp_type (type, arg);
if (!TREE_CONSTANT (arg))
*non_constant_args = true;
+ if (i == 0
+ && DECL_VIRTUAL_P (fun))
+ {
+ tree addr = arg;
+ STRIP_NOPS (addr);
+ if (TREE_CODE (addr) == ADDR_EXPR)
+ {
+ tree obj = TREE_OPERAND (addr, 0);
+ while (TREE_CODE (obj) == COMPONENT_REF
+ && DECL_FIELD_IS_BASE (TREE_OPERAND (obj, 1)))
+ obj = TREE_OPERAND (obj, 0);
+ if (obj != TREE_OPERAND (addr, 0))
+ arg = build_fold_addr_expr_with_type (obj,
+ TREE_TYPE (arg));
+ }
+ }
TREE_VEC_ELT (binds, i) = arg;
}
parms = TREE_CHAIN (parms);
This fixes the testcase. Note, there is still a weird warning:
pr92695.C:3:25: warning: inline function ‘virtual constexpr int A::set(A*)’
used but never defined
3 | constexpr virtual int set (A *o) = 0;
| ^~~