Constantine Black
Constantine Black

Reputation: 203

Overflow in implicit constant conversion [-Werror=overflow]

I am working remotely on a server that uses modules to handle dependencies. I am trying to install dssp (https://github.com/cmbi/dssp) . On github one can see the dependencies.

The modules I have loaded are:

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)

To install, I extract the dssp from tar and tun ./autogen , ./configure and then make. It seems to me that no errors come up on the first two steps but on running make I get:

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

I guess the error is

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

This seems to me to be inside the boost library which is not something I have written. I cannot understand what the error means and I am not a c++ programmer.

Any help would be appreciated.

Upvotes: 1

Views: 903

Answers (1)

eerorika
eerorika

Reputation: 238451

I guess the error is

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

You guess correctly. That is the error, or rather the warning that was asked to be treated as an error.

This seems to me to be inside the boost library

Yes, that is where the "error" is.

I cannot understand what the error means

The type of header_ is std::string and its compound assignment operator accepts a char as right hand operand. However, int was passed instead. Thus, there is an implicit conversion from int to char. On the target system, not all values of int can be represented in the type char, and therefore the value may be altered by this conversion.

The compiler was asked to warn about implicit conversions that potentially alter the value, and to treat such warnings as errors. Therefore the existence of such conversion in the Boost header causes the compilation to fail.

Any help would be appreciated.

Ways to make this compile; any of these should work:

  • Use newer version of Boost. This warning was fixed in version 1.65 which was released about 3 years ago.
  • Do not ask the compiler to treat warnings as errors.
  • Do not ask the compiler to warn about implicit conversions.
  • Ask the compiler to not issue diagnostics from boost headers. This can typically be achieved by specifying the directory that contains boost headers as a "system" include directory.

Upvotes: 2

Related Questions