public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marek Polacek <polacek@redhat.com>
To: Jason Merrill <jason@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH v2] c++: Extend -Wredundant-move for const-qual objects [PR90428]
Date: Wed, 17 Aug 2022 15:09:36 -0400	[thread overview]
Message-ID: <Yv088FT7qQHdZbHz@redhat.com> (raw)
In-Reply-To: <219680be-9ebc-a2aa-c6c6-4f1d2d8f1e8f@redhat.com>

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


      reply	other threads:[~2022-08-17 19:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-06 18:13 [PATCH] " Marek Polacek
2022-08-06 23:58 ` Jason Merrill
2022-08-08 20:27   ` [PATCH v2] " Marek Polacek
2022-08-09 15:08     ` Marek Polacek
2022-08-15 19:43     ` Jason Merrill
2022-08-17 19:09       ` Marek Polacek [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yv088FT7qQHdZbHz@redhat.com \
    --to=polacek@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).