C++ 隐式常量转换中溢出[-Werror=溢出]
我正在使用模块处理依赖关系的服务器上远程工作。我正在尝试安装dssp()。在github上可以看到依赖项 我加载的模块有:C++ 隐式常量转换中溢出[-Werror=溢出],c++,gcc,installation,makefile,C++,Gcc,Installation,Makefile,我正在使用模块处理依赖关系的服务器上远程工作。我正在尝试安装dssp()。在github上可以看到依赖项 我加载的模块有: Currently Loaded Modules: 1) slurm/18-08-4-1-hits 4) numactl/.2.0.10-GCC-4.8.4 (H) 7) OpenBLAS/0.2.13-GCC-4.8.4- LAPACK-3.5.0 10) ScaLAPACK/2.0.2-gompi-1.7.20-OpenBLAS-0.2.13-LAPACK-
Currently Loaded Modules:
1) slurm/18-08-4-1-hits 4) numactl/.2.0.10-GCC-4.8.4 (H) 7) OpenBLAS/0.2.13-GCC-4.8.4-
LAPACK-3.5.0 10) ScaLAPACK/2.0.2-gompi-1.7.20-OpenBLAS-0.2.13-LAPACK-3.5.0 13)
zlib/.1.2.8-goolf-1.7.20 (H)
2) sge/dummy 5) hwloc/.1.10.1-GCC-4.8.4 (H) 8) gompi/1.7.20
11) goolf/1.7.20 14) Boost/1.58.0-goolf-
1.7.20
3) GCC/4.8.4 6) OpenMPI/1.8.4-GCC-4.8.4 9) FFTW/3.3.4-gompi-1.7.20
12) bzip2/.1.0.6-goolf-1.7.20 (H)
为了安装,我从tar和tun中提取dssp./autogen、./configure,然后生成。在我看来,前两步没有出现错误,但在运行时,我得到:
In file included from src/mkdssp.cpp:26:0:
/hits/sw/shared/apps/Boost/1.58.0-goolf-1.7.20/include/boost/iostreams/filter/gzip.hpp: In
instantiation of
‘boost::iostreams::basic_gzip_compressor<Alloc>::basic_gzip_compressor(const
boost::iostreams::gzip_params&, int) [with Alloc = std::allocator<char>]’:
src/mkdssp.cpp:173:38: required from here
/hits/sw/shared/apps/Boost/1.58.0-goolf-
1.7.20/include/boost/iostreams/filter/gzip.hpp:674:13: error: overflow in implicit constant
conversion [-Werror=overflow]
header_ += gzip::magic::id2; // ID2.
^
cc1plus: all warnings being treated as errors
在我看来,这似乎是在boost库中,这不是我写的东西。我不能理解错误是什么意思,我不是C++程序员。
任何帮助都将不胜感激
我想错误是
error: overflow in implicit constant conversion [-Werror=overflow]
header_ += gzip::magic::id2; // ID2.
error: overflow in implicit constant conversion [-Werror=overflow]
header_ += gzip::magic::id2; // ID2.
你猜对了。这就是错误,或者更确切地说是被要求作为错误处理的警告
在我看来,这似乎是在boost库中
是的,这就是“错误”所在
我不明白这个错误是什么意思
头
的类型是std::string
,其复合赋值运算符接受一个char
作为右操作数。但是,却传递了int
。因此,存在从int
到char
的隐式转换。在目标系统上,并非所有的int
值都可以用类型char
表示,因此该值可以通过此转换进行更改
编译器被要求对可能改变值的隐式转换发出警告,并将此类警告视为错误。因此,Boost头中存在这种转换会导致编译失败
任何帮助都将不胜感激
如何使这一目标得以实现;其中任何一项都应该有效:
- 使用更新版本的Boost。此警告在大约3年前发布的1.65版中已修复
- 不要要求编译器将警告视为错误
- 不要要求编译器警告隐式转换
- 要求编译器不要从boost头发出诊断。这通常可以通过将包含boost头的目录指定为“system”include目录来实现