mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Damian McGuckin <damianm@esi.com.au>
To: musl@lists.openwall.com
Subject: Re: sqrt does not emit errno=EDOM
Date: Thu, 3 Jul 2025 18:00:40 +1000 (AEST)	[thread overview]
Message-ID: <5db7df90-7aed-c781-863c-2bf62a43a683@esi.com.au> (raw)
In-Reply-To: <p9u01pqx90s3.fsf@araignee.loria.fr>


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


  reply	other threads:[~2025-07-03  8:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-03  7:44 [musl] sqrt does not emit errno=EDOM Paul Zimmermann
2025-07-03  8:00 ` Damian McGuckin [this message]
2025-07-03 20:05 ` Rich Felker
2025-07-04  9:00   ` Paul Zimmermann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5db7df90-7aed-c781-863c-2bf62a43a683@esi.com.au \
    --to=damianm@esi.com.au \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).