https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93043
Bug ID: 93043 Summary: fails to compile comparison between pointer and convertible to nullptr_t Product: gcc Version: 9.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gccbugbjorn at fahller dot se Target Milestone: --- Created attachment 47541 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47541&action=edit Failing example program For all versions of gcc, but specifically 9.2.1 and trunk 20191215, the following program fails to compile: #include <cstddef> struct indirect_null { inline operator std::nullptr_t() const; }; int* pi = nullptr; bool b = pi == indirect_null{}; The error message is: bf :-) confuciusornis /tmp> g++-9 -std=c++17 t.cpp t.cpp:8:13: error: no match for ‘operator==’ (operand types are ‘int*’ and ‘indirect_null’) 8 | bool b = pi == indirect_null{}; | ~~ ^~ ~~~~~~~~~~~~~~~ | | | | int* indirect_null bf :-( confuciusornis /tmp> g++-9 --version g++-9 (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. A more elaborate test program version can be found on https://godbolt.org/z/aCerqy which shows that the test works for user defined types with a matching operator== as a member function, but not for a fundamental pointer type.