On Tue, Sep 27, 2022 at 05:44:12PM -0400, Jason Merrill wrote:
> On 9/27/22 16:26, Marek Polacek wrote:
> > --- a/gcc/cp/typeck.cc
> > +++ b/gcc/cp/typeck.cc
> > @@ -11042,8 +11042,13 @@ check_return_expr (tree retval, bool *no_warning)
> >      the conditions for the named return value optimization.  */
> >         bool converted = false;
> >         tree moved;
> > -      /* This is only interesting for class type.  */
> > -      if (CLASS_TYPE_P (functype)
> > +      /* Until C++23, this was only interesting for class type...  */
> > +      if ((CLASS_TYPE_P (functype)
> > +      /* ...but in C++23, we should do the below when we're converting
> > +         from/to a class/reference (a non-scalar type).  */
> > +      || (cxx_dialect >= cxx23
> > +          && (!SCALAR_TYPE_P (functype)
> > +              || !SCALAR_TYPE_P (TREE_TYPE (retval)))))
> 
> You might reformat this as
> (cxx_dialect < cxx23
>  ? CLASS...
>  : (!SCALAR...

Done, I like that better.
 
> > --- a/gcc/testsuite/g++.dg/cpp0x/move-return3.C
> > +++ b/gcc/testsuite/g++.dg/cpp0x/move-return3.C
> > @@ -1,6 +1,7 @@
> >   // PR c++/91212
> >   // Test that C++11 implicit move semantics don't call the const copy.
> > -// { dg-do link }
> > +// In C++23, we call #2.
> 
> I guess that behavior is tested by elision2.C:twelve()?

Yeah, I think that's exactly the same case.
 
> > --- a/gcc/testsuite/g++.old-deja/g++.mike/p2846b.C
> > +++ b/gcc/testsuite/g++.old-deja/g++.mike/p2846b.C
> > @@ -1,4 +1,4 @@
> > -// { dg-do run  }
> > +// { dg-do run { target c++20_down } }
> >   // Shows that problem of initializing one object's secondary base from
> >   // another object via a user defined copy constructor for that base,
> >   // the pointer for the secondary vtable is not set after implicit
> > @@ -11,6 +11,8 @@
> >   // prms-id: 2846
> > +// This test fails in C++23 due to P2266.
> 
> Instead of disabling this test for C++23, let's add a cast to B& in the
> return statement.

Fixed.

> OK with that change and optionally the ?: reformatting above.

Thanks a lot; patch pushed.

Marek

Reply via email to