On Tue, May 7, 2019 at 4:43 PM Jason Merrill <ja...@redhat.com> wrote: > > * typeck.c (build_static_cast_1): Use cp_build_addr_expr. > > For GCC 9 I fixed this bug with a patch to gimplify_cond_expr, but this > function was also doing the wrong thing. > > Using build_address does not push the ADDR_EXPR down into the arms of a > COND_EXPR, which we need for proper handling of conversion of an lvalue ?: > to another reference type.
And that allows the gimplifier to assert that we should never see a COND_EXPR of addressable type. Tested x86_64-pc-linux-gnu, applying to trunk.
commit c4f1e37204aaea7efb2aa7dc234d5c8ebeba1089 Author: Jason Merrill <ja...@redhat.com> Date: Mon Mar 4 14:09:57 2019 -0500 * gimplify.c (gimplify_cond_expr): Don't check TREE_ADDRESSABLE. The front end shouldn't produce a GENERIC COND_EXPR of TREE_ADDRESSABLE type. diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 5bacb255ba7..6905165ad33 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -3990,10 +3990,12 @@ gimplify_cond_expr (tree *expr_p, gimple_seq *pre_p, fallback_t fallback) tree result; /* If either an rvalue is ok or we do not require an lvalue, create the - temporary. But we cannot do that if the type is addressable. */ + temporary. We cannot do that if the type is addressable, but + that should have been avoided before we got here. */ if (((fallback & fb_rvalue) || !(fallback & fb_lvalue)) - && !TREE_ADDRESSABLE (type)) + && (flag_checking || !TREE_ADDRESSABLE (type))) { + gcc_assert (!TREE_ADDRESSABLE (type)); if (gimplify_ctxp->allow_rhs_cond_expr /* If either branch has side effects or could trap, it can't be evaluated unconditionally. */