【问题标题】:Overflow in implicit constant conversion [-Werror=overflow]隐式常量转换溢出 [-Werror=overflow]
【发布时间】:2021-01-02 11:39:33
【问题描述】:

我正在使用模块来处理依赖关系的服务器上远程工作。我正在尝试安装 dssp (https://github.com/cmbi/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-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 中提取 dssp 并 tun ./autogen , ./configure 然后 make。在我看来,前两个步骤没有出现错误,但运行 make 我得到:

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

我猜错误是

error: overflow in implicit constant conversion [-Werror=overflow]
header_ += gzip::magic::id2;                         // ID2.

在我看来,这似乎在我没有写过的 boost 库中。我无法理解错误的含义,而且我不是 C++ 程序员。

任何帮助将不胜感激。

【问题讨论】:

    标签: c++ gcc installation makefile


    【解决方案1】:

    我猜错误是

    error: overflow in implicit constant conversion [-Werror=overflow]
    header_ += gzip::magic::id2;                         // ID2.
    

    你猜对了。那就是错误,或者更确切地说是被要求视为错误的警告。

    在我看来这在 boost 库中

    是的,这就是“错误”所在。

    我无法理解错误的含义

    header_ 的类型是std::string,它的复合赋值运算符接受char 作为右手操作数。但是,int 被传递了。因此,存在从intchar 的隐式转换。在目标系统上,并非int 的所有值都可以用char 类型表示,因此该转换可能会更改该值。

    要求编译器警告可能会改变值的隐式转换,并将此类警告视为错误。因此Boost头中存在这种转换会导致编译失败。

    任何帮助将不胜感激。

    编译的方法;这些中的任何一个都应该起作用:

    • 使用较新版本的 Boost。此警告已在大约 3 年前发布的 1.65 版中得到修复。
    • 不要要求编译器将警告视为错误。
    • 不要要求编译器警告隐式转换。
    • 要求编译器不要从 boost 标头发出诊断信息。这通常可以通过将包含 boost 标头的目录指定为“系统”包含目录来实现。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-27
      • 1970-01-01
      相关资源
      最近更新 更多