make SimpleWallet fails on GCC-6.4 -Werror checks

in #utopian-io7 years ago (edited)

Building SimpleWallet fails with 3 different errors related to GCC -Werror checks.

  • -Werror=unused-const-variable
  • -Werror=terminate (see also #1)
  • -Werror=logical-op

System:

# cat /etc/redhat-release
Fedora release 25 (Twenty Five)
# uname -r
4.12.8-200.fc25.x86_64
# gcc --version
gcc (GCC) 6.4.1 20170727 (Red Hat 6.4.1-1)
[...]
# cmake --version
cmake version 3.9.1
[...]

Building via

mkdir build
cd build
cmake ..
make SimpleWallet

Expected behavior

make SimpleWallet runs through without errors

Actual behavior

3 different compile errors due to warnings treated as errors via -Werror:

[ 24%] Building C object src/CMakeFiles/Crypto.dir/crypto/oaes_lib.c.o
/root/tmpfs/dinastycoin/src/crypto/oaes_lib.c:30:19: error: ‘_NR’ defined but not used [-Werror=unused-const-variable=]
 static const char _NR[] = {
                   ^~~
/root/tmpfs/dinastycoin/src/crypto/slow-hash.cpp: In destructor ‘Crypto::cn_context::~cn_context()’:
/root/tmpfs/dinastycoin/src/crypto/slow-hash.cpp:70:23: error: throw will always call terminate() [-Werror=terminate]
       throw bad_alloc();
/root/tmpfs/dinastycoin/src/Platform/Linux/System/TcpConnection.cpp: In member function ‘size_t System::TcpConnection::read(uint8_t*, size_t)’:
/root/tmpfs/dinastycoin/src/Platform/Linux/System/TcpConnection.cpp:84:26: error: logical ‘and’ of equal expressions [-Werror=logical-op]
     if (errno != EAGAIN  && errno != EWOULDBLOCK) {

Workaround:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 290f843..52851d1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -53,7 +53,7 @@ else()
   else()
     set(ARCH_FLAG "-march=${ARCH}")
   endif()
-  set(WARNINGS "-Wall -Wextra -Wpointer-arith -Wundef -Wvla -Wwrite-strings -Werror -Wno-error=extra -Wno-error=unused-function -Wno-error=deprecated-declarations -Wno-error=sign-compare -Wno-error=strict-aliasing -Wno-error=type-limits -Wno-unused-parameter -Wno-error=unused-variable -Wno-error=undef -Wno-error=uninitialized -Wno-error=unused-result")
+  set(WARNINGS "-Wall -Wextra -Wpointer-arith -Wundef -Wvla -Wwrite-strings -Werror -Wno-error=extra -Wno-error=unused-function -Wno-error=deprecated-declarations -Wno-error=sign-compare -Wno-error=strict-aliasing -Wno-error=type-limits -Wno-unused-parameter -Wno-error=unused-variable -Wno-error=undef -Wno-error=uninitialized -Wno-error=unused-result -Wno-error=unused-const-variable -Wno-error=terminate -Wno-error=misleading-indentation -Wno-error=logical-op")
   if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
     set(WARNINGS "${WARNINGS} -Wno-error=mismatched-tags -Wno-error=null-conversion -Wno-overloaded-shift-op-parentheses -Wno-error=shift-count-overflow -Wno-error=tautological-constant-out-of-range-compare -Wno-error=unused-private-field -Wno-error=unneeded-internal-declaration -Wno-error=unused-function -Wno-error=missing-braces")
   else()

Appying these changes makes SimpleWallet compile. This is clearly a
workaround and no fix since the original errors found by the compiler
are simply masked for error checking.



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.
Consider using the latest gcc and g++ :P 7.2.0

You can contact us on Discord.
[utopian-moderator]

Hey @stmdev I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Suggestions

  • Contribute more often to get higher and higher rewards. I wish to see you often!
  • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!

Get Noticed!

  • Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.15
TRX 0.25
JST 0.037
BTC 94201.05
ETH 1794.04
USDT 1.00
SBD 0.87