[webkit-dev] -Wpessimizing-move and -Wredundant-move

Emilio Cobos Álvarez emilio at crisal.io
Tue Mar 19 06:01:17 PDT 2019

On 19/03/2019 00:56, Michael Catanzaro wrote:
> On Mon, Mar 18, 2019 at 4:43 PM, Andy Estes <aestes at apple.com> wrote:
>> FWIW, Apple’s ports use the equivalent clang warning for pessimizing
>> and redundant moves, and we cleaned up a bunch of these mistakes in
>> our ports a few years ago. Hopefully you aren’t finding any of these
>> mistakes in shared code.
> There are a lot, actually. Maybe clang only has -Wpessimizing-move
> (which caused relatively few warnings) and not -Wredundant-move (which
> caused very many). I'm not actually sure what the difference is; in both
> cases, a local variable is cast to rvalue reference via std::move before
> it is returned.

IIRC, clang only warns when using std::move, not a similarly defined
function (like WTFMove, presumably).

In Gecko, when I switched from mozilla::Move to std::move [1], I had to
disable the warning and fix all of them in a followup, since clang
didn't use to warn about them.

If gcc is able to warn more generally, that may explain what you're seeing.

 -- Emilio

[1]: https://bugzilla.mozilla.org/show_bug.cgi?id=1465585

More information about the webkit-dev mailing list