mattgodbolt / seasocks

Simple, small, C++ embeddable webserver with WebSockets support
BSD 2-Clause "Simplified" License
724 stars 120 forks source link

Release mode build fails Werror-unused-result #114

Closed twanas closed 5 years ago

twanas commented 5 years ago

The change made in this commit https://github.com/mattgodbolt/seasocks/commit/a611a8737a724623354690d6b81994524f60bf32#diff-4ff79b629439550b99df4bdba3567373 breaks Release mode builds with -Werror=unused-result.

Tried making a pull request but had no permissions.

Please revert this commit.

Thanks

offa commented 5 years ago

Hi @twanas, we need some more information from you to investigate this.

Tried making a pull request but had no permissions.

You have to create a fork in order to create pull requests. Please see the Github help here). Let me know if you still have problems or need some help.

twanas commented 5 years ago

Hi @offa

Thanks for your reply, I have created a pull request & provided full details of OS and build fail log below.

I was compiling the latest version of the master branch, without any additional settings.

The cmake build flag was -DCMAKE_BUILD_TYPE=Release (See below for more details).

Machine Details

OS: Ubuntu 18.04 Linux wasp-sting 4.15.0-44-generic #47-Ubuntu SMP Mon Jan 14 11:26:59 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

GCC: g++ (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 CMake: cmake version 3.10.2

Build Log

twanas@wasp-sting:~$ cd ~/Downloads/
twanas@wasp-sting:~/Downloads$ git clone https://github.com/mattgodbolt/seasocks.git
Cloning into 'seasocks'...
remote: Enumerating objects: 226, done.
remote: Counting objects: 100% (226/226), done.
remote: Compressing objects: 100% (164/164), done.
remote: Total 4577 (delta 129), reused 116 (delta 58), pack-reused 4351
Receiving objects: 100% (4577/4577), 1.20 MiB | 316.00 KiB/s, done.
Resolving deltas: 100% (2784/2784), done.
twanas@wasp-sting:~/Downloads$ cd seasocks/
twanas@wasp-sting:~/Downloads/seasocks$ mkdir build
twanas@wasp-sting:~/Downloads/seasocks$ cd build
twanas@wasp-sting:~/Downloads/seasocks/build$ cmake .. -DCMAKE_BUILD_TYPE=Release && make
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Seasocks 1.4.1
-- Unittests: ON
-- Coverage: OFF
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Using Python: '/usr/bin/python'
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/twanas/Downloads/seasocks/build
[  1%] Generating embedded content
Scanning dependencies of target embedded
[  3%] Building CXX object src/main/web/CMakeFiles/embedded.dir/Embedded.cpp.o
[  3%] Built target embedded
Scanning dependencies of target seasocks_obj
[  5%] Building CXX object src/main/c/CMakeFiles/seasocks_obj.dir/Connection.cpp.o
[  7%] Building CXX object src/main/c/CMakeFiles/seasocks_obj.dir/HybiAccept.cpp.o
[  9%] Building CXX object src/main/c/CMakeFiles/seasocks_obj.dir/HybiPacketDecoder.cpp.o
[ 11%] Building CXX object src/main/c/CMakeFiles/seasocks_obj.dir/internal/Base64.cpp.o
[ 12%] Building CXX object src/main/c/CMakeFiles/seasocks_obj.dir/Logger.cpp.o
[ 14%] Building CXX object src/main/c/CMakeFiles/seasocks_obj.dir/md5/md5.cpp.o
[ 16%] Building CXX object src/main/c/CMakeFiles/seasocks_obj.dir/PageRequest.cpp.o
[ 18%] Building CXX object src/main/c/CMakeFiles/seasocks_obj.dir/Response.cpp.o
[ 20%] Building CXX object src/main/c/CMakeFiles/seasocks_obj.dir/seasocks/Request.cpp.o
[ 22%] Building CXX object src/main/c/CMakeFiles/seasocks_obj.dir/seasocks/ResponseBuilder.cpp.o
[ 24%] Building CXX object src/main/c/CMakeFiles/seasocks_obj.dir/seasocks/ResponseCode.cpp.o
[ 25%] Building CXX object src/main/c/CMakeFiles/seasocks_obj.dir/seasocks/StreamingResponse.cpp.o
[ 27%] Building CXX object src/main/c/CMakeFiles/seasocks_obj.dir/seasocks/SynchronousResponse.cpp.o
[ 29%] Building CXX object src/main/c/CMakeFiles/seasocks_obj.dir/Server.cpp.o
[ 31%] Building CXX object src/main/c/CMakeFiles/seasocks_obj.dir/sha1/sha1.cpp.o
[ 33%] Building CXX object src/main/c/CMakeFiles/seasocks_obj.dir/StringUtil.cpp.o
/home/twanas/Downloads/seasocks/src/main/c/StringUtil.cpp: In function ‘std::__cxx11::string seasocks::getLastError()’:
/home/twanas/Downloads/seasocks/src/main/c/StringUtil.cpp:79:15: error: ignoring return value of ‘char* strerror_r(int, char*, size_t)’, declared with attribute warn_unused_result [-Werror=unused-result]
     strerror_r(errno, errbuf, sizeof(errbuf));
     ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
src/main/c/CMakeFiles/seasocks_obj.dir/build.make:422: recipe for target 'src/main/c/CMakeFiles/seasocks_obj.dir/StringUtil.cpp.o' failed
make[2]: *** [src/main/c/CMakeFiles/seasocks_obj.dir/StringUtil.cpp.o] Error 1
CMakeFiles/Makefile2:1050: recipe for target 'src/main/c/CMakeFiles/seasocks_obj.dir/all' failed
make[1]: *** [src/main/c/CMakeFiles/seasocks_obj.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
offa commented 5 years ago

Strange, the CI builds (incl. GCC 7) on Ubuntu 14.04 Trusty are ok, even in Release. Same on my System, with latest GCC and Clang.

I'm going to check with 16.04. Let's see, if it shows up there.

Update

Travis' GCC on Xenial doesn't produce this error.

offa commented 5 years ago

Fixed by #115