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

Harald van Dijk <harald at gigawatt dot nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |harald at gigawatt dot nl

--- Comment #5 from Harald van Dijk <harald at gigawatt dot nl> ---
(In reply to Xi Ruoyao from comment #4)
> Here x*y-*x*y evaluates as inf - inf = nan, not 0.  The reference
> implementation in C23 G.5.1p6 evaluates the result as nan too.

That is not "the reference implementation", that is one possible
implementation, and that implementation is immediately followed by an
acknowledgement that it produces less than ideal results:

  "This implementation achieves the required treatment of infinities at the
cost of only one isnan test in ordinary (finite) cases. It is less than ideal
in that undue overflow and underflow could occur."

I think this bug is valid as a enhancement request.

It would be possible to handle this case fairly easily without loss of
precision by scaling: we can divide the complex values by 2 before doing the
complex multiplication, and multiply the result by 4. Whether that is always
possible, though, I do not know.

Reply via email to