Follow @Openwall on Twitter for new release announcements and other news
[<prev] [<thread-prev] [day] [month] [year] [list]
Message-ID: <5db7df90-7aed-c781-863c-2bf62a43a683@esi.com.au>
Date: Thu, 3 Jul 2025 18:00:40 +1000 (AEST)
From: Damian McGuckin <damianm@....com.au>
To: musl@...ts.openwall.com
Subject: Re: sqrt does not emit errno=EDOM


Hi Paul,

On Thu, 3 Jul 2025, Paul Zimmermann wrote:

> it seems musl does not set errno=EDOM for sqrt(x) when x is negative.
> Here on cfarm27 (Alpine Linux):
>
> $ cat /tmp/e.c
> #include <stdio.h>
> #include <math.h>
> #include <errno.h>
>
> int
> main()
> {
>  errno = 0;
>  float x = -1.0f;
>  float y = sqrtf (x);
>  printf ("y=%a errno=%d\n", y, errno);
> }
>
> $ gcc /tmp/e.c -lm
> $ ./a.out
> y=-nan errno=0
>
> Is this a known issue?

I think it is a policy issue:

 	Errors are reported by raising floating-point status flags ie.
 	math_errhandling is set to MATH_ERREXCEPT on all platforms (errno
 	is not set by math functions and on platforms without IEEE 754
 	exception semantics there is no error reporting).

Later - Damian

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.