Bug 68258

Summary: core 879 Missing built-in comparison operators for pointer types not supported
Product: gcc Reporter: derrick
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: daniel.kruegler, gabravier, webrown.cpp
Priority: P3 Keywords: rejects-valid
Version: 4.8.2   
Target Milestone: 11.0   
See Also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87699
Host: Target:
Build: Known to work:
Known to fail: 6.0 Last reconfirmed: 2015-11-10 00:00:00

Description derrick 2015-11-09 18:05:29 UTC
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#879
not implemented, while clang3.6 works.
Code:

#include <cstddef>
struct X_
        {
        operator std::nullptr_t() { return nullptr; }
        };
struct Y_
        {
        operator std::nullptr_t() { return nullptr; }
        };
int main()
{
    X_ x;
    Y_ y;
    bool z = x != y;

    return 0;
}

Compile error:
main.cpp: In function 'int main()':

main.cpp:15:28: error: no match for 'operator!=' (operand types are 'X_' and 'Y_')

                 bool z = x != y;

                            ^
Comment 1 Richard Biener 2015-11-10 09:29:17 UTC
Confirmed.
Comment 2 Andrew Pinski 2021-07-23 02:59:32 UTC
Fixed in GCC 11 by r11-467:
        * call.c (add_builtin_candidate) <case EQ_EXPR>: Create candidate
        operator functions when type is std::nullptr_t for ==/!=.