It's a shame that -fno-math-errno isn't the default. It pessimizes many common operations, as can be seen in the article. Also e.g. a simple sqrt() call like<p>#include <math.h><p>double mysqrt(double d) {
return sqrt(d);
}<p>with and without -fno-math-errno: <a href="https://godbolt.org/z/bvrz9r8ce" rel="nofollow">https://godbolt.org/z/bvrz9r8ce</a><p>One can see that with -fno-math-errno the function can be entirely inlined. But if errno is enabled, it has to first check whether the input is negative, and in that case call the libc sqrt() function which sets errno.<p>As for why it's not the default, I guess it's historical. The errno approach was common back in the days before IEEE 754 with its exception model provided another way.<p>E.g. for glibc: <a href="https://man7.org/linux/man-pages/man7/math_error.7.html" rel="nofollow">https://man7.org/linux/man-pages/man7/math_error.7.html</a><p>Musl libc, being newer, does away with that and never sets errno in libm functions: <a href="https://wiki.musl-libc.org/mathematical-library.html" rel="nofollow">https://wiki.musl-libc.org/mathematical-library.html</a>