Commit a8959ecf authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

C++20: work around g++ 10.1 bug #95242

With GCC 10.1 all comparisons that default to the <=> C++20 comparison
operator emit a spurious zero-as-null-pointer-constant warning, which
is an error in our configuration.  This is due to an implementation
choice in the libstdc++ library, so it also causes warning from
clang++ 10.0 when using the same libstdc++ library.  A fix for GCC
PR95242 was committed in g++ (not in libstdc++), so while g++ 10.2
might be fixed, clang++ will need a similar fix.

I've seen those failures on Arch linux with gcc 10.1.0-2 and clang
10.0.0-3.  On Debian sid, g++ 10.1.0-4 seems to already include the

* m4/gccwarn.m4: Include a string comparison in the test code so that
-Wzero-as-null-pointer-constant is not enabled if it would produce
warnings on such statements.
parent 368acaad
Pipeline #20479 failed with stage
in 98 minutes and 3 seconds
......@@ -20,7 +20,21 @@ AC_DEFUN([CF_GXX_WARNINGS],
cat > conftest.$ac_ext <<EOF
#line __oline__ "configure"
int main(int argc, char *argv[[]]) { return argv[[argc-1]] == nullptr; }
#include <string>
int main(int argc, char *argv[[]])
// This string comparison is here to detect superfluous
// zero-as-null-pointer-constant errors introduced with GCC 10.1's
// libstdc++,
// This is fixed in g++ 10.2, but has the fix is in the compiler
// instead of the library, clang++ 10.0 also has trouble with it.
// If we hit a compiler with this issue, we simply do not use
// -Wzero-as-null-pointer-constant.
std::string a{"foo"}, b{"bar"};
if (b < a)
return 1;
return argv[[argc-1]] == nullptr;
ac_cv_prog_gxx_warn_flags="-W -Wall"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment