https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124935

--- Comment #2 from Heiko Eißfeldt <heiko at hexco dot de> ---
Regarding "ordered comparison of pointer with null pointer"

I tried to come up with a demo program for a to-be-created explicit warning
option
based on the test ordered-comparison-4.c from the testsuite.

nullptr is available since C23. It is a non-lvalue of type nullptr_t, so
different from void *.

https://godbolt.org/z/b58ccxEbr

```C
int main(void)
{
    void *v;
    char *c;
    if (c < (char *)0) /* no warning with -Wextra why? */
    if (c < (char *)nullptr) /* no warning with -Wextra why? */
    if (c < nullptr) /* ordered comparison of pointer with integer zero? */
    if (v < nullptr) /* ordered comparison of pointer with integer zero? */
    return v < (void *)0;  /* ordered comparison of pointer with null pointer
*/
}
```
but I fail to understand the logic for warnings here.
I would expect the same type of warning for all comparisons here.

Is this warning behavior really ok for C23 or does nullptr_t needs some extra
treatment?
Thanks!

Reply via email to