lhmouse/asteria

Build failure on GCC 7.3, due to -Wstrict-overflow=2

Closed this issue · 6 comments

In file included from asteria/src/rocket/cow_string.hpp:21:0,
                 from asteria/src/rocket/insertable_streambuf.hpp:9,
                 from asteria/src/rocket/insertable_streambuf.cpp:4:
asteria/src/rocket/cow_string.hpp: In destructor ‘rocket::basic_insertable_streambuf<charT, traitsT, allocatorT>::~basic_insertable_streambuf() [with charT = char; traitsT = std::char_traits<char>; allocatorT = std::allocator<char>]’:
asteria/src/rocket/assert.hpp:19:62: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
 #  define ROCKET_DETAILS_ASSERT(expr_, str_, m_)    ((expr_) ? (void)0 : ROCKET_UNREACHABLE())
                                                     ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
asteria/src/rocket/assert.hpp:22:43: note: in expansion of macro ‘ROCKET_DETAILS_ASSERT’
 #define ROCKET_ASSERT(expr_)              ROCKET_DETAILS_ASSERT(expr_, #expr_, "")
                                           ^~~~~~~~~~~~~~~~~~~~~
asteria/src/rocket/cow_string.hpp:166:15: note: in expansion of macro ‘ROCKET_ASSERT’
               ROCKET_ASSERT(old > 0);
               ^~~~~~~~~~~~~
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)

I have the same clang++ version but get no such warnings or errors. Would you please provide the full command line you are using to compile that file ?

Maybe e1cc7f6 can fix this ?

That makes the build go further, but it still fails for the ROCKET_ASSERT(len >= 0); in line 2233.

And my apologies, it seems that the build actually uses g++ rather than clang++:

echo "  CXX     " asteria/src/rocket/cow_string.lo;depbase=`echo asteria/src/rocket/cow_string.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
/bin/bash ./libtool --silent --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I.  -Wall -Wextra -Wconversion -Wsign-conversion -Winvalid-pch -Wwrite-strings -Wswitch-enum -Wsuggest-attribute=noreturn -Wno-error=pragmas -Wundef -Wshadow -Wstrict-aliasing=2 -Wstrict-overflow=2 -Wno-error=pragmas -Wno-error=unused-{function,variable,parameter} -pipe -fPIC -DPIC -pthread -Werror  -std=c++11 -Wnon-virtual-dtor -g -O2 -MT asteria/src/rocket/cow_string.lo -MD -MP -MF $depbase.Tpo -c -o asteria/src/rocket/cow_string.lo asteria/src/rocket/cow_string.cpp &&\
gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0

Yeah, confirmed with GCC 7.3.

Fixed on master. Thanks for the report. 👍

Fix confirmed.