This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 108i. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2022-07-16


583. Relational pointer comparisons against the null pointer constant

Section: 7.6.9  [expr.rel]     Status: CD3     Submitter: James Widman     Date: 24 May 2006

[Moved to DR status at the April, 2013 meeting as paper N3624.]

In C, this is ill-formed (cf C99 6.5.8):

    void f(char* s) {
        if (s < 0) { }
    }

...but in C++, it's not. Why? Who would ever need to write (s > 0) when they could just as well write (s != 0)?

This has been in the language since the ARM (and possibly earlier); apparently it's because the pointer conversions (7.3.12 [conv.ptr]) need to be performed on both operands whenever one of the operands is of pointer type. So it looks like the "null-ptr-to-real-pointer-type" conversion is hitching a ride with the other pointer conversions.

Proposed resolution (April, 2013):

This issue is resolved by the resolution of issue 1512.