https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96278
Bug ID: 96278 Summary: three-way comparison operator comparison to 0: spurious nullptr warning Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gu...@henkel-wallace.org Target Milestone: --- Bug in g++ 10.1.0 with libstdc++ compile following program doing `g++-10 -std=c++20 -Wzero-as-null-pointer-constant` #include <iostream> #include <compare> int main () { bool result { (1 <=> 2) < 0 }; std::cout << (result ? "Yes" : "No") << std::endl; } produces the error: foo.cc:5:27: warning: zero as null pointer constant [-Wzero-as-null-pointer-constant] Also compiler-synthesized comparisons will generate this which is especially confusing as they can happen when calling a library function that needs the '<' operator. the exact version of GCC: 10.1.0 the system type: MacOS 10.15 (and Ubuntu 18.4 LTS using apt-get of gcc 10) the options given when GCC was configured/built: (homebrew version): Configured with: ../configure --build=x86_64-apple-darwin19 --prefix=/usr/local/Cellar/gcc/10.1.0 --libdir=/usr/local/Cellar/gcc/10.1.0/lib/gcc/10 --disable-nls --enable-checking=release --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-10 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --with-pkgversion='Homebrew GCC 10.1.0' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk SED=/usr/bin/sed