RESOLVED FIXED225205
-Wpessimizing-move warnings in LocaleICU.cpp
https://bugs.webkit.org/show_bug.cgi?id=225205
Summary -Wpessimizing-move warnings in LocaleICU.cpp
Michael Catanzaro
Reported 2021-04-29 13:04:32 PDT
It looks like GCC 11 has improved its -Wpessimizing-move warning: [2866/5471] Building CXX object Source/WebCore/CMakeFiles...edSources/unified-sources/UnifiedSource-3c72abbe-58.cpp.o In file included from WTF/Headers/wtf/FastMalloc.h:26, from ../../Source/WebCore/config.h:56, from ../../Source/WebCore/platform/text/TextEncodingRegistry.cpp:27, from WebCore/DerivedSources/unified-sources/UnifiedSource-3c72abbe-58.cpp:1: ../../Source/WebCore/platform/text/LocaleICU.cpp: In member function ‘std::unique_ptr<WTF::Vector<WTF::String> > WebCore::LocaleICU::createLabelVector(void* const*, UDateFormatSymbolType, int32_t, int32_t)’: WTF/Headers/wtf/StdLibExtras.h:563:58: warning: moving a local object in a return statement prevents copy elision [-Wpessimizing-move] 563 | #define WTFMove(value) std::move<WTF::CheckMoveParameter>(value) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ ../../Source/WebCore/platform/text/LocaleICU.cpp:185:12: note: in expansion of macro ‘WTFMove’ 185 | return WTFMove(labels); | ^~~~~~~ WTF/Headers/wtf/StdLibExtras.h:563:58: note: remove ‘std::move’ call 563 | #define WTFMove(value) std::move<WTF::CheckMoveParameter>(value) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ ../../Source/WebCore/platform/text/LocaleICU.cpp:185:12: note: in expansion of macro ‘WTFMove’ 185 | return WTFMove(labels); | ^~~~~~~ ../../Source/WebCore/platform/text/LocaleICU.cpp: In function ‘std::unique_ptr<WTF::Vector<WTF::String> > WebCore::createFallbackMonthLabels()’: WTF/Headers/wtf/StdLibExtras.h:563:58: warning: moving a local object in a return statement prevents copy elision [-Wpessimizing-move] 563 | #define WTFMove(value) std::move<WTF::CheckMoveParameter>(value) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ ../../Source/WebCore/platform/text/LocaleICU.cpp:194:12: note: in expansion of macro ‘WTFMove’ 194 | return WTFMove(labels); | ^~~~~~~ WTF/Headers/wtf/StdLibExtras.h:563:58: note: remove ‘std::move’ call 563 | #define WTFMove(value) std::move<WTF::CheckMoveParameter>(value) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ ../../Source/WebCore/platform/text/LocaleICU.cpp:194:12: note: in expansion of macro ‘WTFMove’ 194 | return WTFMove(labels); | ^~~~~~~ ../../Source/WebCore/platform/text/LocaleICU.cpp: In function ‘std::unique_ptr<WTF::Vector<WTF::String> > WebCore::createFallbackAMPMLabels()’: WTF/Headers/wtf/StdLibExtras.h:563:58: warning: moving a local object in a return statement prevents copy elision [-Wpessimizing-move] 563 | #define WTFMove(value) std::move<WTF::CheckMoveParameter>(value) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ ../../Source/WebCore/platform/text/LocaleICU.cpp:216:12: note: in expansion of macro ‘WTFMove’ 216 | return WTFMove(labels); | ^~~~~~~ WTF/Headers/wtf/StdLibExtras.h:563:58: note: remove ‘std::move’ call 563 | #define WTFMove(value) std::move<WTF::CheckMoveParameter>(value) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ ../../Source/WebCore/platform/text/LocaleICU.cpp:216:12: note: in expansion of macro ‘WTFMove’ 216 | return WTFMove(labels); | ^~~~~~~ This case is a little interesting because the return value is a std::unique_ptr, which is noncopyable. I can see why using WTFMove for that would be tempting. But it's not needed for a return value.
Attachments
Patch (2.03 KB, patch)
2021-04-29 13:05 PDT, Michael Catanzaro
no flags
Michael Catanzaro
Comment 1 2021-04-29 13:05:33 PDT
EWS
Comment 2 2021-04-29 15:34:13 PDT
Committed r276813 (237173@main): <https://commits.webkit.org/237173@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 427371 [details].
Radar WebKit Bug Importer
Comment 3 2021-04-29 15:35:18 PDT
Note You need to log in before you can comment on or make changes to this bug.