On Wed, May 22, 2019 at 05:59:56PM -0400, Jason Merrill wrote: > 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. I think this broke a lot in the D testsuite: +FAIL: gdc.test/runnable/link15017.d (internal compiler error) +UNRESOLVED: gdc.test/runnable/link15017.d compilation failed to produce executable +FAIL: gdc.test/runnable/sdtor.d -O2 (internal compiler error) +UNRESOLVED: gdc.test/runnable/sdtor.d -O2 compilation failed to produce executable +FAIL: gdc.test/runnable/testaa.d (internal compiler error) +UNRESOLVED: gdc.test/runnable/testaa.d compilation failed to produce executable +FAIL: libphobos.druntime/rt/lifetime.d (test for excess errors) +UNRESOLVED: libphobos.druntime/rt/lifetime.d compilation failed to produce executable +FAIL: libphobos.druntime_shared/rt/lifetime.d (test for excess errors) +UNRESOLVED: libphobos.druntime_shared/rt/lifetime.d compilation failed to produce executable +FAIL: libphobos.phobos/std/uni.d (test for excess errors) +UNRESOLVED: libphobos.phobos/std/uni.d compilation failed to produce executable +FAIL: libphobos.phobos_shared/std/uni.d (test for excess errors) +UNRESOLVED: libphobos.phobos_shared/std/uni.d compilation failed to produce executable (the list is reduced, so that for each failing tests there aren't many lines). Iain, is that something that can be fixed on the D FE side? > --- 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. */ Jakub