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

    <tr>
        <th>Summary</th>
        <td>
            clang 19 raises operator<=>() return type to std::strong_ordering for double
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    This program compiles with clang 19.1.2 but fails to compile with MSVC 19.41:

```c++
#include <compare>

class C
{
    double d1;
    double d2;
    std::strong_ordering operator<=>(const C&) const = default;
};

int main()
{
    return 0;
}
```

The MSVC error message:

> main.cpp(7): error C7549: 'C::operator <=>': 
> defaulted comparison function cannot be declared to return a comparison 
> category stronger than the common category among bases and members which was deduced to be 'std::partial_ordering'

In my opinion MSVC is correct because double by default only supports std::partial_ordering because of NaN values.

See also here: https://en.cppreference.com/w/cpp/utility/compare/partial_ordering

> The built-in operator<=>between floating-point values uses this ordering:
> the positive zero and the negative zero compare equivalent, but can be 
> distinguished, and NaN values compare unordered with any other value.

Why does clang compile the code?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0VE2P4zYM_TXKhZjAluw4Ofgwm9kAPXQvu2iPBS0xtlpZcvUxg_TXF7Kdr_0ADCcmyCc-vidiCLq3RC2rP7H6bYMpDs630z_m0Gw6py7tt0EHmLzrPY4g3ThpQwE-dBxAGrQ9lIdtueXQpQhn1CZAdNe8Je33r38cc1ZVMvHKijdWXN-7Ynkk45_ys0S50FaapAiYOGYk9MTE58dKaTAEOK6hZq0EAFAudYZAlUz8JMqfoiGq3JF4DdE72__lvCKvbQ9uIo_ReSaOTLzls_leOhsiHBnfMX6A5YuJN1B0xmTiDZg1b_f_81vbCCNqy_ie8cNPevYUk7dQPGE8T-gR79tAy0zJe-dhpBCwp-9nKz7Ph27lNDG-b_LJ4nUtOTZ1N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