weidai11 / cryptopp

free C++ class library of cryptographic schemes
https://cryptopp.com
Other
4.85k stars 1.5k forks source link

Enable compiler warnings #555

Closed EduardoMiravalls closed 6 years ago

EduardoMiravalls commented 6 years ago

Hello CryptoPP mantainers: maybe it's already been answered already, but I haven't found it anywhere: why does CyproPP's makefile not enable compiler warnings?

Some header files give warnings If I #include them, mostly signed and unsigned comparisons. I've seen that you have started fixing warnings in commit 5f083d652e4fb9698e0e22d3629311749d4142a6 and commit ba98c2bfb92eedd541622a2d904a6d4b35b5dd71 in the code, but if you compile the library with -Wall I still get a lot of warnings.

I don't know if all compilers support -Wall, so maybe simply adding CXXFLAGS += -Wall may break the compilation for some environments, but at least both g++ and clangsupport that option.

Thank you, and happy new year!

noloader commented 6 years ago

I haven't found it anywhere: why does CyproPP's makefile not enable compiler warnings?

cryptest.sh performs the testing that can generate a lot of noise. It uses -Wall, -Wextra and others. Search the script for the word "elevated".

I've seen that you have started fixing warnings

It is an on-going effort.

Some header files give warnings ...

If you have specific instances we can fix them.


If you are interested in the script, I usually run it with:

./cryptest.sh fast

One of the output artifacts is cryptest-warn.txt. I usually thumb through it looking for sore spots.

If you omit fast then you get Valgrind and benchmarks tests, too. They add hours to the tests so I run it less frequently.

You can avoid the script with a simple:

CXXFLAGS="-DNDEBUG -g2 -O3 -Wall -Wextra" make -j 4

Based on -Wall -Wextra with GCC 7, it looks like I introduced a few new ones due to clang-tidy on eccrypto.cpp.

The unknown pragmas usually pollute my log files. I think they are a GCC bug. Also see Issue 66943, GCC warns of Unknown Pragma for OpenMP, even though it support it.


Here is what I am seeing under GCC 7.2

skylake:cryptopp$ CXXFLAGS="-DNDEBUG -g2 -O3 -Wall -Wextra" make -j 4
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c cryptlib.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c cpu.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c integer.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c 3way.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c adler32.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c algebra.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c algparam.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c arc4.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -mssse3 -c aria-simd.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c aria.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c ariatab.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c asn.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c authenc.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c base32.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c base64.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c basecode.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c bfinit.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -msse4.1 -c blake2-simd.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c blake2.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c blowfish.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c blumshub.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c camellia.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c cast.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c casts.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c cbcmac.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c ccm.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c chacha.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c channels.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c cmac.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -msse4.2 -c crc-simd.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c crc.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c default.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c des.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c dessp.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c dh.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c dh2.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c dll.cpp
dll.cpp:13:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable: 4191)

g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c dsa.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c eax.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c ec2n.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c eccrypto.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c ecp.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c elgamal.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c emsa2.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c eprecomp.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c esign.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c files.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c filters.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c fips140.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c fipstest.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -mssse3 -mpclmul -c gcm-simd.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c gcm.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c gf256.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c gf2_32.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c gf2n.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c gfpcrypt.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c gost.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c gzip.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c hex.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c hmac.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c hrtimer.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c ida.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c idea.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c iterhash.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c kalyna.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c kalynatab.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c keccak.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c luc.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c mars.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c marss.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c md2.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c md4.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c md5.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c misc.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c modes.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c mqueue.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c mqv.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c nbtheory.cpp
nbtheory.cpp:650:0: warning: ignoring #pragma omp parallel [-Wunknown-pragmas]
  #pragma omp parallel

nbtheory.cpp:651:0: warning: ignoring #pragma omp sections [-Wunknown-pragmas]
   #pragma omp sections

nbtheory.cpp:653:0: warning: ignoring #pragma omp section [-Wunknown-pragmas]
    #pragma omp section

nbtheory.cpp:655:0: warning: ignoring #pragma omp section [-Wunknown-pragmas]
    #pragma omp section

nbtheory.cpp:1002:0: warning: ignoring #pragma omp parallel [-Wunknown-pragmas]
  #pragma omp parallel

nbtheory.cpp:1003:0: warning: ignoring #pragma omp sections [-Wunknown-pragmas]
   #pragma omp sections

nbtheory.cpp:1005:0: warning: ignoring #pragma omp section [-Wunknown-pragmas]
    #pragma omp section

nbtheory.cpp:1010:0: warning: ignoring #pragma omp section [-Wunknown-pragmas]
    #pragma omp section

g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c neon-simd.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c network.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c oaep.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c ospstore.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c osrng.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c padlkrng.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c panama.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c pkcspad.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c poly1305.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c polynomi.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c ppc-simd.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c pssr.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c pubkey.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c queue.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c rabin.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c randpool.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c rc2.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c rc5.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c rc6.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c rdrand.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c rdtables.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -msse4.1 -maes -c rijndael-simd.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c rijndael.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c ripemd.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c rng.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c rsa.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c rw.cpp
rw.cpp:129:0: warning: ignoring #pragma omp parallel [-Wunknown-pragmas]
  #pragma omp parallel sections if(CRYPTOPP_RW_USE_OMP)

rw.cpp:131:0: warning: ignoring #pragma omp section [-Wunknown-pragmas]
   #pragma omp section

rw.cpp:133:0: warning: ignoring #pragma omp section [-Wunknown-pragmas]
   #pragma omp section

rw.cpp:135:0: warning: ignoring #pragma omp section [-Wunknown-pragmas]
   #pragma omp section

rw.cpp:227:0: warning: ignoring #pragma omp parallel [-Wunknown-pragmas]
  #pragma omp parallel sections if(CRYPTOPP_RW_USE_OMP)

rw.cpp:229:0: warning: ignoring #pragma omp section [-Wunknown-pragmas]
   #pragma omp section

rw.cpp:233:0: warning: ignoring #pragma omp section [-Wunknown-pragmas]
   #pragma omp section

g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c safer.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c salsa.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c seal.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c seed.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c serpent.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -msse4.2 -msha -c sha-simd.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c sha.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c sha3.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -msse4.2 -msha -c shacal2-simd.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c shacal2.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c shark.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c sharkbox.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -msse4.1 -c simon-simd.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c simon.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c skipjack.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c sm3.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c sm4.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c socketft.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c sosemanuk.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -msse4.1 -c speck-simd.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c speck.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c square.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c squaretb.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c sse-simd.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c strciphr.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c tea.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c tftables.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c threefish.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c tiger.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c tigertab.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c trdlocal.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c ttmac.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c twofish.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c vmac.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c wait.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c wake.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c whrlpool.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c xtr.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c xtrcrypt.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c zdeflate.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c zinflate.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c zlib.cpp
cp adhoc.cpp.proto adhoc.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c test.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c bench1.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c bench2.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c validat0.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c validat1.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c validat2.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c validat3.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c datatest.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c regtest1.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c regtest2.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c regtest3.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c dlltest.cpp
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c fipsalgt.cpp
ar r libcryptopp.a cryptlib.o cpu.o integer.o 3way.o adler32.o algebra.o algparam.o arc4.o aria-simd.o aria.o ariatab.o asn.o authenc.o base32.o base64.o basecode.o bfinit.o blake2-simd.o blake2.o blowfish.o blumshub.o camellia.o cast.o casts.o cbcmac.o ccm.o chacha.o channels.o cmac.o crc-simd.o crc.o default.o des.o dessp.o dh.o dh2.o dll.o dsa.o eax.o ec2n.o eccrypto.o ecp.o elgamal.o emsa2.o eprecomp.o esign.o files.o filters.o fips140.o fipstest.o gcm-simd.o gcm.o gf256.o gf2_32.o gf2n.o gfpcrypt.o gost.o gzip.o hex.o hmac.o hrtimer.o ida.o idea.o iterhash.o kalyna.o kalynatab.o keccak.o luc.o mars.o marss.o md2.o md4.o md5.o misc.o modes.o mqueue.o mqv.o nbtheory.o neon-simd.o network.o oaep.o ospstore.o osrng.o padlkrng.o panama.o pkcspad.o poly1305.o polynomi.o ppc-simd.o pssr.o pubkey.o queue.o rabin.o randpool.o rc2.o rc5.o rc6.o rdrand.o rdtables.o rijndael-simd.o rijndael.o ripemd.o rng.o rsa.o rw.o safer.o salsa.o seal.o seed.o serpent.o sha-simd.o sha.o sha3.o shacal2-simd.o shacal2.o shark.o sharkbox.o simon-simd.o simon.o skipjack.o sm3.o sm4.o socketft.o sosemanuk.o speck-simd.o speck.o square.o squaretb.o sse-simd.o strciphr.o tea.o tftables.o threefish.o tiger.o tigertab.o trdlocal.o ttmac.o twofish.o vmac.o wait.o wake.o whrlpool.o xtr.o xtrcrypt.o zdeflate.o zinflate.o zlib.o
ar: creating libcryptopp.a
ranlib libcryptopp.a
g++ -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe -c adhoc.cpp
g++ -o cryptest.exe -DNDEBUG -g2 -O3 -Wall -Wextra -fPIC -pthread -pipe adhoc.o test.o bench1.o bench2.o validat0.o validat1.o validat2.o validat3.o datatest.o regtest1.o regtest2.o regtest3.o dlltest.o fipsalgt.o ./libcryptopp.a
EduardoMiravalls commented 6 years ago

Thanks for your quick response. I agree that some warnings are very verbose and pollute the compile logs.

If you have specific instances we can fix them.

Well, I don't know if they are fixed in master, but at least from version 5.6.5 I get a warning in line 218 of seckey.h

libs/cryptopp565/seckey.h: In static member function ‘static size_t CryptoPP::VariableKeyLength<D, N, M, Q, IV_REQ, IV_L>::StaticGetValidKeyLength(size_t) [with unsigned int D = 16u, unsigned int N = 0u, unsigned int M = 2147483647u, unsigned int Q = 1u, unsigned int IV_REQ = 4u, unsigned int IV_L = 0u]’:
libs/cryptopp565/seckey.h:304:   instantiated from ‘size_t CryptoPP::SimpleKeyingInterfaceImpl<BASE, INFO>::GetValidKeyLength(size_t) const [with BASE = CryptoPP::HMAC_Base, INFO = CryptoPP::HMAC<CryptoPP::SHA256>]’
libs/cryptopp565/seckey.h:218: warning: comparison of unsigned expression < 0 is always false

Without c++11 support, the only work around I found is the one I give in this SO answer https://stackoverflow.com/a/47871053 , but I don't know if it works for all compilers.

noloader commented 6 years ago

but at least from version 5.6.5 I get a warning in line 218 of seckey.h

You should consider working from Master. It is mostly stable with an occasional break. We usually catch the breaks quickly.

Master also has lots of new algorithms, and almost all hardware acceleration we can find. I'm working on Power8 SHA at the moment.

Without c++11 support, the only work around I found is the one I give in this SO answer https://stackoverflow.com/a/47871053

Yeah, I'm familiar with those. GCC has -Wtype-limits and Clang has -Wtautological-compare.

In modern compilers we control it with code like below:

// Issue 340
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wconversion"
# pragma GCC diagnostic ignored "-Wsign-conversion"
#endif

...

// Issue 340
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
# pragma GCC diagnostic pop
#endif

For example, misc.h and IntToString is one of those pain points, and it uses:

#if CRYPTOPP_MSC_VERSION
# pragma warning(push)
# pragma warning(disable: 4389)
#endif

#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wsign-compare"
# if (CRYPTOPP_LLVM_CLANG_VERSION >= 20800) || (CRYPTOPP_APPLE_CLANG_VERSION >= 30000)
#  pragma GCC diagnostic ignored "-Wtautological-compare"
# elif (CRYPTOPP_GCC_VERSION >= 40300)
#  pragma GCC diagnostic ignored "-Wtype-limits"
# endif
#endif

Unfortunately, from my notes in config.h:

// Need GCC 4.6/Clang 1.7/Apple Clang 2.0 or above due to "GCC diagnostic {push|pop}"
#if (CRYPTOPP_GCC_VERSION >= 40600) || (CRYPTOPP_LLVM_CLANG_VERSION >= 10700) || (CRYPTOPP_APPLE_CLANG_VERSION >= 20000)
    #define CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE 1
#endif

So we are not going to be able to help with GCC 4.4 or 4.5.

noloader commented 6 years ago

Related, our VM with the website and wiki is CentOS 7. We enable SCL ports so we can get Python 2.7 and PHP 7. Maybe you can do similar with Red Hat and update the compiler to GCC 4.6 so pragma GCC diagnostic {push|pop} is available.

EduardoMiravalls commented 6 years ago

Ok, I'll have a look at that, thanks.

noloader commented 6 years ago

@EduardoMiravalls,

If I were wearing your shoes, then I would take this approach to testing. It is kind of needed because of that old compiler and the library's inability to easily manage warnings. Since we can't easily manage them we side step the issue with older compilers.

Setup another VM with something more modern. Maybe Debian 8 or Fedora 26 or CentOS 7. Then, run your testing on the newer platform. You can crank up warnings like you want. You also have access to the sanitizers. Test everything under the newer platform and know that it applies to older platforms.

And to be clear, there are some warnings we live with but suppress. Uri (@mouse07410 ) wants to clear them but we usually spend resources on more interesting things, like fixing bugs and Power8 AES or SHA. As a compromise we used pragmas to manage them.

Related, see Release Process | Analysis Tools on the Crypto++ wiki. They are the tests we use for the library.

noloader commented 6 years ago

@EduardoMiravalls,

Is there anything else we can do here? If not, can we close it?

EduardoMiravalls commented 6 years ago

Yeah, thank you.