From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 74D9B3858400 for ; Tue, 27 Sep 2022 23:39:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 74D9B3858400 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664321973; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+q2lx+okOQycm9N7yeKT2VxeMHihIxyRoeHSn5j01RU=; b=QkJD+nelDunIJHX1/Xgwh04AtELfalUhgDFO05+7HawtB5vJvXo16cogtGgQd/dSBjaI+u gBBuyKiaXgCFGaLe9aYeWTqwA7ITitqOnP5OhHvNwOP/y442/JpHmUzHHMj1U4cdWGRgVk riQW+bL+XlIQ5DSJ9OtbvBmUdcYV/jw= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-593-MoZ0GqiMMm-d82mHiEEETg-1; Tue, 27 Sep 2022 19:39:28 -0400 X-MC-Unique: MoZ0GqiMMm-d82mHiEEETg-1 Received: by mail-qt1-f197.google.com with SMTP id fe14-20020a05622a4d4e00b0035cc376b1d5so7826165qtb.4 for ; Tue, 27 Sep 2022 16:39:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date; bh=+q2lx+okOQycm9N7yeKT2VxeMHihIxyRoeHSn5j01RU=; b=WRapbcrHdng/89i0stE4MvxBjkKETf2DLPWRbSJLnr6GKitDBF85c5T6vyVWfhzdaL 0mvpx/yOQD4oe2EGLX2SjIVjNV6xzSx4KoLbZYwrzQxvGZsrxENvPTdJwV7WsC+gvLTi VnrkbFRor4hf5Viig2cM1CsUID0fcSmGjiCOhLpJy+qU02w+l3g+TxaEwUTIPJ+aTweB dDKVL7t0KC5bugkBgR6t+f8M6Bb0xCoTF4Ua+4GDTgijEGgrBrKayYYTWlB7ryy8U2tV wlYCDJVyM+uJ1yknThenMJ+7u12ko/G1p6Bawm5hOqG8MvQPz4CzsfhhKobbhqAQ1HZB zxzw== X-Gm-Message-State: ACrzQf0BbshU6UdyX6GGyUkmHa/YvXUZzW1/f4VS0btsCab0cShJdju9 RbNekgIZm2MbrST0ab/DUbEVK4Mw9Qwzd6CmBGWE1XKxo7+YBb1Ui+6drI+D7vKlUEmWIyw705F PY8DLgddOjn9TE/Mbbg== X-Received: by 2002:a37:5386:0:b0:6cf:759b:c866 with SMTP id h128-20020a375386000000b006cf759bc866mr16105264qkb.261.1664321968323; Tue, 27 Sep 2022 16:39:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM62Lh8sBtBlXsS2MEE0GKdGBC7YhznHG9knHd3yskzhS/FqB+XAKIHPgM9ywjL+D16WanqNfw== X-Received: by 2002:a37:5386:0:b0:6cf:759b:c866 with SMTP id h128-20020a375386000000b006cf759bc866mr16105255qkb.261.1664321968065; Tue, 27 Sep 2022 16:39:28 -0700 (PDT) Received: from redhat.com (2603-7000-9500-2e39-0000-0000-0000-1db4.res6.spectrum.com. [2603:7000:9500:2e39::1db4]) by smtp.gmail.com with ESMTPSA id n6-20020a05620a294600b006cbc00db595sm1913635qkp.23.2022.09.27.16.39.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 16:39:27 -0700 (PDT) Date: Tue, 27 Sep 2022 19:39:25 -0400 From: Marek Polacek To: Jason Merrill Cc: GCC Patches Subject: Re: [PATCH v3] c++: Implement C++23 P2266R1, Simpler implicit move [PR101165] Message-ID: References: <20220903164200.17908-1-polacek@redhat.com> <9f9f6d62-c3c8-083e-d30d-808076c01eca@redhat.com> <548cdcb9-abed-ef66-0dfd-5264cfa4ff3c@redhat.com> <39fb63d9-8128-512b-523d-f575317cf7c2@redhat.com> MIME-Version: 1.0 In-Reply-To: <39fb63d9-8128-512b-523d-f575317cf7c2@redhat.com> User-Agent: Mutt/2.2.7 (2022-08-07) X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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