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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-04-28
     Ever confirmed|0                           |1

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
While it's not the cause of the bad codegen for the <=> comparisons, this test
shouldn't even be using <=>. The problem is that the synthesized operator> that
is based on <=> is a better match for non-const durations than the one that
would generate good code:

If you write it like this you get good codegen:

bool compare(const clk::duration& a, const clk::duration& b)
{
    return a > b;
}

In fact you don't even need to pass them by reference, just:

bool compare(const clk::duration a, const clk::duration b)
{
    return a > b;
}

This seems like a defect in the std::lib, but it's separate from the poor
codegen for the <=> comparison.

Reply via email to