Compiling nghttp2 1.62.0 fails on stable Linux distros that use gcc 11 as their compiler, such as the stable Slackware 15.0 which uses gcc 11.2.0. Compiling against gcc-13 works fine. The previous versions of nghttp2, 1.61.0 and below, are not affected.
Example:
# make V=1
make all-recursive
make[3]: Entering directory 'nghttp2-1.62.0/src'
depbase=`echo util.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
g++ -std=gnu++20 -DHAVE_CONFIG_H -I. -I.. -DPKGDATADIR='"/usr/share/nghttp2"' -DPKGLIBDIR='"/usr/lib64/nghttp2"' -I../lib/includes -I../lib/includes -I../lib -I../third-party -I../third-party/llhttp/include -I/usr/include/libxml2 -DHAVE_CONFIG_H -g -O2 -fPIC -march=opteron -MT util.o -MD -MP -MF $depbase.Tpo -c -o util.o util.cc &&\
mv -f $depbase.Tpo $depbase.Po
In file included from util.h:57,
from util.cc:25:
template.h: In constructor ‘constexpr nghttp2::ImmutableString::ImmutableString(const string&)’:
template.h:233:19: error: call to non-‘constexpr’ function ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]’
233 | : len(s.size()), base(copystr(std::begin(s), std::end(s))) {}
| ~~~~~~^~
In file included from /usr/include/c++/11.2.0/string:55,
from util.h:42,
from util.cc:25:
/usr/include/c++/11.2.0/bits/basic_string.h:919:7: note: ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]’ declared here
919 | size() const _GLIBCXX_NOEXCEPT
| ^~~~
As a possible workaround, I tried switching between std=c++20 and std=gnu++20 and std=c++17, optionally with HAVE_CXX20=0, but all of those failed with more errors.
Compiling nghttp2 1.62.0 fails on stable Linux distros that use gcc 11 as their compiler, such as the stable Slackware 15.0 which uses gcc 11.2.0. Compiling against gcc-13 works fine. The previous versions of nghttp2, 1.61.0 and below, are not affected.
Example:
As a possible workaround, I tried switching between std=c++20 and std=gnu++20 and std=c++17, optionally with
HAVE_CXX20=0, but all of those failed with more errors.