Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 1 Oct 2019 19:28:13 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: Patch for cacosh

On Tue, Oct 01, 2019 at 09:57:17PM +0000, Michael Morrell wrote:
> Running the gcc validation suite, I noticed that
> gfortran.dg/complex_intrinsic_5.f90 was failing when using MUSL.
> 
> I tracked it down to the cacosh routines not getting the correct
> result when the imaginary part of the argument was negative.
> 
> Attached is a patch to fix this.

Thanks!

> diff --git a/src/complex/cacosh.c b/src/complex/cacosh.c
> index 8c68cb01..0b598052 100644
> --- a/src/complex/cacosh.c
> +++ b/src/complex/cacosh.c
> @@ -4,6 +4,9 @@
>  
>  double complex cacosh(double complex z)
>  {
> +        _Bool zineg = cimag(z) < 0;
> +

I think this fails to give the desired result for negative zero.
Should probably be signbit(cimag(z)) or similar.

If there's a way to adjust the input to cacos to avoid having to patch
up after it returns based on a flag saved before the call, that would
make it more efficient I think (no need to spill/reload), but it's not
a big deal if not.

Also, as a style matter, musl codebase generally doesn't use _Bool;
rather just int for flags/boolean values.

Rich

Powered by blists - more mailing lists

Your e-mail address:

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