On Tue, Feb 05, 2019 at 04:17:48PM -0500, Jason Merrill wrote:
> On 2/5/19 3:43 PM, Marek Polacek wrote:
> > On Tue, Feb 05, 2019 at 01:24:15PM -0500, Jason Merrill wrote:
> > > On 2/5/19 11:31 AM, Jakub Jelinek wrote:
> > > > On Tue, Feb 05, 2019 at 11:24:14AM -0500, Jason Merrill wrote:
> > > > > Yes, thanks, mark_rvalue_use is definitely wrong here.  But 
> > > > > mark_lvalue_use
> > > > > might be wrong as well; we don't know here how the expression is used 
> > > > > by the
> > > > > inner conversions for the user-defined conversion.  Can we remove the 
> > > > > call
> > > > > entirely?  It doesn't seem to break any Wunused* tests.
> > > > 
> > > > It was added in r159096 for -Wunused-but-set*.  It is surely possible 
> > > > it is
> > > > now covered by other mark_*_use calls.  Or could we call there just
> > > > mark_exp_read instead?
> > > 
> > > That would be fine too.
> > 
> > So how about this if it passes testing?
> > 
> > Bootstrapped/regtested running on x86_64-linux, ok for trunk/8?
> > 
> > 2019-02-05  Marek Polacek  <pola...@redhat.com>
> > 
> >     PR c++/89158 - by-value capture of constexpr variable broken.
> >     * call.c (convert_like_real) <case ck_user>: Call mark_exp_read
> >     instead of mark_rvalue_use.
> > 
> >     * g++.dg/cpp0x/lambda/lambda-89158.C: New test.
> > 
> > diff --git gcc/cp/call.c gcc/cp/call.c
> > index c74d1b4ebdf..020a095dade 100644
> > --- gcc/cp/call.c
> > +++ gcc/cp/call.c
> > @@ -7006,7 +7006,9 @@ convert_like_real (conversion *convs, tree expr, tree 
> > fn, int argnum,
> >         return expr;
> >       }
> > -   expr = mark_rvalue_use (expr);
> > +   /* Calling mark_rvalue_use could turn a decl into a constant, breaking
> > +      e.g. the need_temporary_p assumption in the ICS.  */
> > +   mark_exp_read (expr);
> 
> I'd describe the issue at a higher level, e.g. "we don't know here whether
> expr is being used as an lvalue or rvalue".  mark_rvalue_use is wrong for
> this testcase because expr is actually used as an lvalue.  OK with that
> change.

Will do, thanks!

Marek

Reply via email to