From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 893753858CDA; Sun, 23 Oct 2022 09:43:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 893753858CDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666518187; bh=DTeJlQgZYuDhqRgHF57TvM40rgtrf10hvByb8kms2Hg=; h=From:To:Subject:Date:From; b=TlF0AeyzDCMgeNUs0MejyqP7jMVzjdpXev334aljFlIXgTjRutucSsc0gRnO00aRh OtsBC+RCZPlZLDj1wFgIemk4zaR8cMaCU+Q2Q8hsApj2FrxKed1ewgRWa6oZI53Ca0 iDw2K4oAGl0YTpG/5qJA20YjqrGUB7aAYu+6KXlo= From: "dani at danielbertalan dot dev" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107363] New: Wrong caret location for "redundant move in return statement" Date: Sun, 23 Oct 2022 09:43:04 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dani at danielbertalan dot dev X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107363 Bug ID: 107363 Summary: Wrong caret location for "redundant move in return statement" Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: dani at danielbertalan dot dev Target Milestone: --- The caret in the following "redundant move in return statement" warning does not point to a return statement (https://godbolt.org/z/4v7Y9G9e3): ``` #include template struct Optional { T &value(); T release_value() { T released_value =3D std::move(value()); return released_value; } }; struct Foo {}; void test(Optional o) { o.release_value(); } ``` :7:7: warning: redundant move in return statement [-Wredundant-move] 7 | T released_value =3D std::move(value()); | ^~~~~~~~~~~~~~ :7:7: note: remove 'std::move' call As an aside, it's a bit annoying to have this warning when the moved type depends on a template parameter in library code. We are forced to either silence this warning with a #pragma, or use concepts to have a variant of t= he release_value method that does not call std::move for const-qualified T.=