Bug 225205

Summary: -Wpessimizing-move warnings in LocaleICU.cpp
Product: WebKit Reporter: Michael Catanzaro <mcatanzaro>
Component: WebCore Misc.Assignee: Michael Catanzaro <mcatanzaro>
Status: RESOLVED FIXED    
Severity: Normal CC: mcatanzaro, sam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: PC   
OS: Linux   
Attachments:
Description Flags
Patch none

Description Michael Catanzaro 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.
Comment 1 Michael Catanzaro 2021-04-29 13:05:33 PDT
Created attachment 427371 [details]
Patch
Comment 2 EWS 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].
Comment 3 Radar WebKit Bug Importer 2021-04-29 15:35:18 PDT
<rdar://problem/77346730>