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

Heiko Eißfeldt <heiko at hexco dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |heiko at hexco dot de

--- Comment #5 from Heiko Eißfeldt <heiko at hexco dot de> ---
Hi, I came upon this while working at PR7651.

@Martin Sebor: since C23 there is also nullptr. Would you mind updating your
patch?

Currently (gcc 16.0) we need -Wextra which gives inconsistent warnings (IMO).

```C
/* compile with -std=c23 -Wextra */
#include <stddef.h>

int main(void)
{
    void *voidp0=0;

    if (nullptr < voidp0)   /* invalid for clang, valid for gcc nullptr seen as
integer 0 */
    if (nullptr < nullptr)  /* but ordered compare cannot have nullptr */
     return 1;
}
```

gives
<source>: In function 'main':
<source>:8:17: warning: ordered comparison of pointer with integer zero
[-Wextra]
    8 |     if (nullptr < voidp0)   /* invalid for clang, valid for gcc nullptr
seen as integer 0 */
      |                 ^
<source>:9:17: error: invalid operands to binary < (have 'typeof (nullptr)' and
'typeof (nullptr)')
    9 |     if (nullptr < nullptr)  /* but ordered compare cannot have nullptr
*/
      |                 ^
Compiler returned: 1

Thanks!

Reply via email to