isl-org/Open3D

error: moving a temporary object prevents copy elision [-Werror=pessimizing-move]

jiapei100 opened this issue · 1 comments

Checklist

Steps to reproduce the issue

I first cloned Open3D by:

git clone https://github.com/isl-org/Open3D.git
cd Open3D

Then, I build Open3D (on Ubuntu 20.04, with CUDA 11.5) with:

mkdir build
cd build
cmake -DBUILD_SHARED_LIBS=ON -DBUILD_CUDA_MODULE=ON -DUSE_BLAS=OFF -DBUILD_WEBRTC=OFF ..
make -j$(nproc)

Error message

[ 64%] Building CXX object cpp/open3d/visualization/CMakeFiles/visualization.dir/rendering/filament/FilamentRenderer.cpp.o
cd ....../Open3D/build/cpp/open3d/visualization && /usr/bin/c++ -DBUILD_GUI -DBUILD_ISPC_MODULE -DFMT_HEADER_ONLY=0 -DFMT_STRING_ALIAS=1 -DFMT_USE_WINDOWS_H=0 -DMKL_ILP64 -DOPEN3D_CUDA_COMPILER_ID=\"\" -DOPEN3D_CUDA_COMPILER_VERSION=\"\" -DOPEN3D_CXX_COMPILER_ID=\"GNU\" -DOPEN3D_CXX_COMPILER_VERSION=\"12.3.0\" -DOPEN3D_CXX_STANDARD=\"14\" -DOPEN3D_ENABLE_DLL_EXPORTS -DUNIX -DWITH_IPPICV -DZMQ_STATIC -D_FORTIFY_SOURCE=2 -D_GLIBCXX_USE_CXX11_ABI=1 -D__TBB_LIB_NAME=tbb_static -I....../Open3D/cpp -isystem ....../Open3D/3rdparty/tomasakeninemoeller/include -isystem ....../Open3D/3rdparty/rply/rply -isystem ....../Open3D/3rdparty/tinyfiledialogs/include -isystem ....../Open3D/build/poisson/src/ext_poisson -isystem ....../Open3D/build/zeromq/include -isystem ....../Open3D/build/zeromq/src/ext_cppzmq -isystem ....../Open3D/build/msgpack-c/src/ext_msgpack-c/include -isystem ....../Open3D/build/vtk/src/ext_vtk/include/vtk-9.1 -isystem ....../Open3D/build/uvatlas/include/DirectXMath -isystem ....../Open3D/build/uvatlas/include -isystem ....../Open3D/build/uvatlas/include/wsl/stubs -isystem ....../Open3D/build/mkl_install/include -isystem /usr/include/jsoncpp -isystem /usr/include/liblzf -isystem /usr/include/minizip -isystem /usr/local/include/imgui -isystem ....../Open3D/build/ippicv/include/icv -isystem ....../Open3D/build/ippicv/include -isystem /usr/include/eigen3 -isystem ....../Open3D/build/parallelstl/src/ext_parallelstl/include -isystem ....../Open3D/build/fmt/include -isystem ....../Open3D/build/filament/src/ext_filament/include -std=c++17 -fPIC -Werror=pessimizing-move -O3 -DNDEBUG -std=c++14 -fPIC -Wall -Wextra -Werror -Wno-unused-parameter -fdiagnostics-color=always -fstack-protector-strong -Wformat -Wformat-security -m64 -fopenmp -MD -MT cpp/open3d/visualization/CMakeFiles/visualization.dir/rendering/filament/FilamentRenderer.cpp.o -MF CMakeFiles/visualization.dir/rendering/filament/FilamentRenderer.cpp.o.d -o CMakeFiles/visualization.dir/rendering/filament/FilamentRenderer.cpp.o -c ....../Open3D/cpp/open3d/visualization/rendering/filament/FilamentRenderer.cpp
In file included from ....../Open3D/cpp/open3d/visualization/rendering/MaterialModifier.h:12,
                 from ....../Open3D/cpp/open3d/visualization/rendering/Renderer.h:10,
                 from ....../Open3D/cpp/open3d/visualization/rendering/filament/FilamentRenderer.h:14,
                 from ....../Open3D/cpp/open3d/visualization/rendering/filament/FilamentRenderer.cpp:8:
....../Open3D/cpp/open3d/visualization/rendering/RendererHandle.h: In instantiation of ‘static open3d::visualization::rendering::REHandle<entityType> open3d::visualization::rendering::REHandle<entityType>::Next() [with open3d::visualization::rendering::EntityType entityType = open3d::visualization::rendering::EntityType::Scene]’:
....../Open3D/cpp/open3d/visualization/rendering/filament/FilamentRenderer.cpp:81:36:   required from here
....../Open3D/cpp/open3d/visualization/rendering/RendererHandle.h:101:38: error: moving a temporary object prevents copy elision [-Werror=pessimizing-move]
  101 |         return std::move(REHandle(id));
      |                                      ^
....../Open3D/cpp/open3d/visualization/rendering/RendererHandle.h:101:38: note: remove ‘std::move’ call
cc1plus: all warnings being treated as errors
make[2]: *** [cpp/open3d/visualization/CMakeFiles/visualization.dir/build.make:807: cpp/open3d/visualization/CMakeFiles/visualization.dir/rendering/filament/FilamentRenderer.cpp.o] Error 1
make[2]: Leaving directory '....../Open3D/build'
make[1]: *** [CMakeFiles/Makefile2:2036: cpp/open3d/visualization/CMakeFiles/visualization.dir/all] Error 2
make[1]: Leaving directory '....../Open3D/build'
make: *** [Makefile:159: all] Error 2

Open3D, Python and System information

- Operating system: Ubuntu 24.04
- Python version: Python 3.12.3
- Open3D version: not installed yet
- System architecture: x86
- Is this a remote workstation?: no
- How did you install Open3D?: build from source
- Compiler version (if built from source): gcc 13.2.0

Additional information

A reference is provided Understanding when not to std::move in C++

Problem solved... lvalue and rvalue issue.
Some std::move need to be removed, but some others need to be kept ...