https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107363
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 <utility> template <typename T> struct Optional { T &value(); T release_value() { T released_value = std::move(value()); return released_value; } }; struct Foo {}; void test(Optional<const Foo> o) { o.release_value(); } ``` <source>:7:7: warning: redundant move in return statement [-Wredundant-move] 7 | T released_value = std::move(value()); | ^~~~~~~~~~~~~~ <source>: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 the release_value method that does not call std::move for const-qualified T.