<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/55919>55919</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            False positive on `-Wzero-as-null-pointer-constant` with spaceship operator
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          brevzin
      </td>
    </tr>
</table>

<pre>
    Reduced from [StackOverflow](https://stackoverflow.com/q/72533435/2069064):

```cpp
#include <compare>

struct quantity {
    int i;
    constexpr auto operator<=>( const quantity& ) const = default;
};

bool f(quantity a, quantity b) {
    return a < b;
}
```

This code, when compiled with `-Wzero-as-null-pointer-constant`, [emits](https://godbolt.org/z/3jvKG67fh):

```
<source>:5:65: error: zero as null pointer constant [-Werror,-Wzero-as-null-pointer-constant]
    constexpr auto operator<=>( const quantity& ) const = default;
                                                                ^
                                                                nullptr
<source>:9:14: note: in defaulted three-way comparison operator for 'quantity' first required here
    return a < b;
             ^
```

But the fact that `a < b` evaluates as `(a <=> b) < 0` and the implementation uses a pointer type for the `0` part of this expression is an implementation detail that the user can't control, this isn't something that should be warned on. It's the language that puts in the `0` and the language that more or less requires that it be implemented as a pointer. 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy1VUtv2zgQ_jX0ZWBDJi3JOuiQxM1isYcFugv0TEkji12aVPiwN_n1HUq24xRBW6CtIErUPD5-8yDV2O65_ohdbLGD3tkDsPz-nyDb__4-ouu1PbF8x_h2CGH0TNwx_ki3Twb2bLBq7YFkTzRKnguxETlNeVZUWbFhvEpe2Y5ll2eRzXc7jmcJF8q0OnYITDwQ2igdMvHh1ssHF9sAT1GaoMIzsPJ-VgBdygRQTNxIWmt8wP9HBzIGC3ZEJ4N1BM_ELkHz7WxzRWS8ACJ7lpIVdNjLqMMVl5W71_n0bKzV0BPWlZZk_O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