From dbcd32f889365695b3ed835a3a7de5d23048f43b Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 5 Mar 2019 17:17:13 -0500 Subject: re PR c++/86485 ("anonymous" maybe-uninitialized false positive with ternary operator) * class.c (is_really_empty_class): Add ignore_vptr parm. While looking at PR86485, I noticed that many uses of is_really_empty_class were overlooking that it returned true for a class with only a vptr; initialization of such a class is not trivial. Marek's P1064 patch fixed one place in constexpr.c to also check for a vtable, but there are several others that still don't. This patch requires callers to explicitly choose which behavior they want. Currently the uses in constexpr.c want to consider the vptr, and other uses don't. * class.c (is_really_empty_class): Add ignore_vptr parm. (trivial_default_constructor_is_constexpr): Pass it. * call.c (build_over_call): Pass it. * constexpr.c (cxx_eval_constant_expression): Pass it instead of checking TYPE_POLYMORPHIC_P. (cxx_eval_component_reference, potential_constant_expression_1): Pass it. * cp-gimplify.c (simple_empty_class_p): Pass it. * init.c (expand_aggr_init_1): Pass it. From-SVN: r269402 --- gcc/cp/call.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cp/call.c') diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 1a29eb7..04516eb 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -8566,7 +8566,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) tree arg = argarray[1]; location_t loc = cp_expr_loc_or_loc (arg, input_location); - if (is_really_empty_class (type)) + if (is_really_empty_class (type, /*ignore_vptr*/true)) { /* Avoid copying empty classes. */ val = build2 (COMPOUND_EXPR, type, arg, to); -- cgit v1.1