Paddle std::move报错

kzipqqlq  于 2022-04-21  发布在  Java
关注(0)|答案(5)|浏览(226)
template <class... ARGS>
std::string format_string(const char* fmt, ARGS&&... args) {
  std::string str;
  format_string_append(str, fmt, args...);
  return std::move(str);
}
template <class... ARGS>
std::string format_string(const std::string& fmt, ARGS&&... args) {
  return format_string(fmt.c_str(), args...);
:wq
   54 |   return std::move(str);
      |                       ^
/opt/Paddle-1.8.3/paddle/fluid/string/string_helper.h:54:23: note: remove 'std::move' call
/opt/Paddle-1.8.3/paddle/fluid/string/string_helper.h: In instantiation of 'std::string paddle::string::format_string(const char*, ARGS&& ...) [with ARGS = {const char*}; std::string =
std::__cxx11::basic_string<char>]':
/opt/Paddle-1.8.3/paddle/fluid/framework/io/fs.cc:115:71:   required from here
/opt/Paddle-1.8.3/paddle/fluid/string/string_helper.h:54:23: error: moving a local object in a return statement prevents copy elision [-Werror=pessimizing-move]
/opt/Paddle-1.8.3/paddle/fluid/string/string_helper.h:54:23: note: remove 'std::move' call
/opt/Paddle-1.8.3/paddle/fluid/string/string_helper.h: In instantiation of 'std::string paddle::string::format_string(const char*, ARGS&& ...) [with ARGS = {const char*, const char*, co
nst char*}; std::string = std::__cxx11::basic_string<char>]':
/opt/Paddle-1.8.3/paddle/fluid/framework/io/fs.cc:345:78:   required from here
/opt/Paddle-1.8.3/paddle/fluid/string/string_helper.h:54:23: error: moving a local object in a return statement prevents copy elision [-Werror=pessimizing-move]
/opt/Paddle-1.8.3/paddle/fluid/string/string_helper.h:54:23: note: remove 'std::move' call
[  5%] Built target data_feed_proto
3xiyfsfu

3xiyfsfu1#

看到您之前提的 issue,是在 alpine 上编译的么?请教了 @tianshuo78520a ,目前应该是只支持在 centos / ubuntu 上的编译。可以尝试使用官网的镜像。

bf1o4zei

bf1o4zei2#

您好,我也是在alpine上进行源码编译遇到了这个问题,请问您有解决办法吗?如果有希望可以分享一下,谢谢~

q5iwbnjs

q5iwbnjs3#

我编译也有同样的错误,编译环境wsl2,ubuntu20.4

deikduxw

deikduxw4#

在CmakeLists.txt加这么一句
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=pessimizing-move")

如果不想从头重新编译,可以找到出问题的build.make同目录下的flags.make
在CXX_FLAGS那一行加上-Wno-error=pessimizing-move

文件比较多,直接上sed
sed -i 's/^CXX_FLAGS(.*)$/CXX_FLAGS\1 -Wno-error=pessimizing-move /' find paddle -type f -name "flags.make"

k4ymrczo

k4ymrczo5#

find SRCROOT -type f -name CMakeLists.txt -exec sed -i -e '$aset(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=pessimizing-move")' {} \;

this quick and dirty hack works for me. If would be better if the maintainer could add -Wno-error=pessimizing-move to the CMakeLists.txt what needs it.

相关问题