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.133.124]) by sourceware.org (Postfix) with ESMTPS id DAD523858D37 for ; Wed, 17 Aug 2022 19:09:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DAD523858D37 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-310-RgWwEThPOaG3gSUUYjdvoQ-1; Wed, 17 Aug 2022 15:09:39 -0400 X-MC-Unique: RgWwEThPOaG3gSUUYjdvoQ-1 Received: by mail-qv1-f69.google.com with SMTP id np4-20020a056214370400b00476809b9caeso6696412qvb.0 for ; Wed, 17 Aug 2022 12:09:39 -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; bh=PZHBMsPmE9aGSW7L6dcRGb6/26xaspuRu0JRiqQqS2A=; b=PlYN+by/kJWzixtpavu5uzGkfocFThMBeTphJDSikT7F7evl4/Utpf/WtoVaTOA1ZX 3qQry4fN0/msZFo0kWP8XdHu5tDnM5Hg260YPQT2mbXOG25FkGb2Kx8ZscTBb17BOHAh rNyJEavVe8fc+DpurmOuAdYKc8LBTIKxHRLDLdSc842deher+sl8C0uhV3TO5IV9UwT/ kiBTw6vqFG1+IzV5Ig4hfc+04DchMQnuqY9oRfYhH3+aRYOkP8+nFuP83Z0xEj58aYAt 1LUNajr/TsK3D/4UkF7OU3sq24C78VErjCqkBZizVWfSS1MR6OAODL5bbCTQaoHIWj/Y Fh2Q== X-Gm-Message-State: ACgBeo0+aBduLo73x+9bt1X2pntdOQSVO6jWV46D1AP3VdGWz4kYCoBd wnMiQDDHZ2RAYi67WVYROXLB1eWz7TDq27KhtyQJKT6noL5brdOJbK//xWS0S9n5F6CXJsD3IzA wyJMDMDAxQnO9q+LEtw== X-Received: by 2002:a05:6214:c23:b0:476:9e4d:174 with SMTP id a3-20020a0562140c2300b004769e4d0174mr23303625qvd.39.1660763378621; Wed, 17 Aug 2022 12:09:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR7wZfKwWHMqYu74cXAaK2BaLkg6TjSqXu5OoebHPkFAUHnheggad427P1cHEktLi15UiHGTEw== X-Received: by 2002:a05:6214:c23:b0:476:9e4d:174 with SMTP id a3-20020a0562140c2300b004769e4d0174mr23303611qvd.39.1660763378439; Wed, 17 Aug 2022 12:09:38 -0700 (PDT) Received: from redhat.com ([2601:184:4780:4310::e531]) by smtp.gmail.com with ESMTPSA id f3-20020a05620a408300b006b9c355ed75sm8715137qko.70.2022.08.17.12.09.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 12:09:37 -0700 (PDT) Date: Wed, 17 Aug 2022 15:09:36 -0400 From: Marek Polacek To: Jason Merrill Cc: GCC Patches Subject: Re: [PATCH v2] c++: Extend -Wredundant-move for const-qual objects [PR90428] Message-ID: References: <20220806181313.337246-1-polacek@redhat.com> <4c50b759-f207-7c80-b3f0-efa00a9b73a6@redhat.com> <219680be-9ebc-a2aa-c6c6-4f1d2d8f1e8f@redhat.com> MIME-Version: 1.0 In-Reply-To: <219680be-9ebc-a2aa-c6c6-4f1d2d8f1e8f@redhat.com> User-Agent: Mutt/2.2.6 (2022-06-05) 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.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Aug 2022 19:09:42 -0000 On Mon, Aug 15, 2022 at 03:43:38PM -0400, Jason Merrill wrote: > On 8/8/22 13:27, Marek Polacek wrote: > > This is to warn about this: > > > > T f5(const T t) > > { > > return std::move(t); // { dg-warning "redundant move" } > > } > > > > where OR fails because there's no T(const T&&) (or it's deleted in which case > > convert_for_initialization also returns error_mark_node). This OR is going to > > fail with std::move but also without std::move when we're trying to treat an lvalue > > as an rvalue. So the std::move has no effect, because T(const T&) will be > > called in either case. > > > > Now, if there was a T(const T&&), we'd *still* warn, because the std::move would > > still be redundant. Does that make sense? > > Ah, so this is because LOOKUP_PREFER_RVALUE returns an error if a const T& > overload is selected. The comment should mention that. OK with that > change. Thanks, pushed. > Since you've been thinking about this area, I wonder if you want to look at > implementing P2266? Yup, I can take a look. It's also come up recently in a discussion with Davis in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89780#c3. Since P2266 was approved, I've updated our C++23 status table as well. Marek