Page MenuHomePhabricator

macOS compile error: moving a local object in a return statement prevents copy elision
Closed, ResolvedPublic

Description

While building "master" branch of MITK on macOS Mojave with

$ clang --version
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

I get the following compile error:

[ 37%] Building CXX object Modules/ImageStatistics/CMakeFiles/MitkImageStatistics.dir/mitkImageStatisticsContainer.cpp.o
/Users/fedorov/github/mitk/Modules/ImageStatistics/mitkImageStatisticsContainer.cpp:78:14: error: moving a local object in a return statement prevents copy elision [-Werror,-Wpessimizing-move]
      return std::move(names);
             ^
/Users/fedorov/github/mitk/Modules/ImageStatistics/mitkImageStatisticsContainer.cpp:78:14: note: remove std::move call here
      return std::move(names);
             ^~~~~~~~~~     ~
/Users/fedorov/github/mitk/Modules/ImageStatistics/mitkImageStatisticsContainer.cpp:187:14: error: moving a local object in a return statement prevents copy elision [-Werror,-Wpessimizing-move]
      return std::move(names);
             ^
/Users/fedorov/github/mitk/Modules/ImageStatistics/mitkImageStatisticsContainer.cpp:187:14: note: remove std::move call here
      return std::move(names);
             ^~~~~~~~~~     ~
/Users/fedorov/github/mitk/Modules/ImageStatistics/mitkImageStatisticsContainer.cpp:207:14: error: moving a local object in a return statement prevents copy elision [-Werror,-Wpessimizing-move]
      return std::move(names);
             ^
/Users/fedorov/github/mitk/Modules/ImageStatistics/mitkImageStatisticsContainer.cpp:207:14: note: remove std::move call here
      return std::move(names);
             ^~~~~~~~~~     ~
3 errors generated.