From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.linux.lib.musl.general/22186 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Damian McGuckin Newsgroups: gmane.linux.lib.musl.general Subject: Re: sqrt does not emit errno=EDOM Date: Thu, 3 Jul 2025 18:00:40 +1000 (AEST) Message-ID: <5db7df90-7aed-c781-863c-2bf62a43a683@esi.com.au> References: Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28498"; mail-complaints-to="usenet@ciao.gmane.io" To: musl@lists.openwall.com Original-X-From: musl-return-22206-gllmg-musl=m.gmane-mx.org@lists.openwall.com Thu Jul 03 10:01:10 2025 Return-path: Envelope-to: gllmg-musl@m.gmane-mx.org Original-Received: from second.openwall.net ([193.110.157.125]) by ciao.gmane.io with smtp (Exim 4.92) (envelope-from ) id 1uXEsY-0007LO-5e for gllmg-musl@m.gmane-mx.org; Thu, 03 Jul 2025 10:01:10 +0200 Original-Received: (qmail 32305 invoked by uid 550); 3 Jul 2025 08:00:59 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: x-ms-reactions: disallow Original-Received: (qmail 32278 invoked from network); 3 Jul 2025 08:00:59 -0000 In-Reply-To: Xref: news.gmane.io gmane.linux.lib.musl.general:22186 Archived-At: 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 > #include > #include > > 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