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 fix. * 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.
This commit is contained in:
parent
368acaad28
commit
a8959ecf81
1 changed files with 15 additions and 1 deletions
|
|
@ -20,7 +20,21 @@ AC_DEFUN([CF_GXX_WARNINGS],
|
||||||
[
|
[
|
||||||
cat > conftest.$ac_ext <<EOF
|
cat > conftest.$ac_ext <<EOF
|
||||||
#line __oline__ "configure"
|
#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++, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95242
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
EOF
|
EOF
|
||||||
cf_save_CXXFLAGS="$CXXFLAGS"
|
cf_save_CXXFLAGS="$CXXFLAGS"
|
||||||
ac_cv_prog_gxx_warn_flags="-W -Wall"
|
ac_cv_prog_gxx_warn_flags="-W -Wall"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue