[PATCH] math: Fix errno setting for narrowing sqrt functions on underflow [BZ #33393]
Wilco Dijkstra
Wilco.Dijkstra@arm.com
Mon Oct 20 00:54:00 GMT 2025
Hi Collin,
>> I don't see an issue that needs to be fixed. errno as a concept is highly problematic
>> to start with.
>
> errno would be fine if every operating system/libc set it to the same
> value in all cases. But that will never happen. :)
Well it's completely inconsistent even within GLIBC itself - what a user gets
depends on historical implementation details rather than a design or a standard.
Why does sqrt() set errno, but fma() does not despite math_errhandling having
MATH_ERRNO set (which requires both to set errno)? In the past when you used
-ffinite-math-only, GLIBC would no longer set errno on some functions. Then there
was the SVID kernel_standard insanity... We still have lots of useless math veneers
that only exist because of errno checks. They slow down math functions by ~10%
on modern hardware eventhough that is completely unnecessary and useless.
So yes, errno considered harmful.
Cheers,
Wilco
More information about the Libc-alpha
mailing list