[webkit-dev] -Wreturn-type and -Wredundant-move reminders
Michael Catanzaro
mcatanzaro at gnome.org
Tue Oct 19 13:15:02 PDT 2021
Hi devs,
A reminder about this common idiom:
switch (...) {
case Foo:
return ...;
case Bar:
return ...;
}
RELEASE_ASSERT_NOT_REACHED();
When it's intended that the code always returns inside the switch
statement, the RELEASE_ASSERT_NOT_REACHED() is required to avoid
tripping GCC's -Wreturn-type. If you forget it, I or somebody else will
wind up adding it later to avoid the warning. Clang does not warn here,
and this is the most common type of warning I clean up, so please don't
forget! :) This warning is useful in other situations, and it seems
nicer to placate GCC than to disable it.
I'll sneak in another reminder: "return WTFMove()" is almost always not
needed. Clang warns only if the move prevents return value
optimization, but GCC will always warn if it detects the move is
unneeded.
Have a nice day,
Michael
More information about the webkit-dev
mailing list