Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sat, 21 Nov 2015 21:32:45 +0100
From: u-uy74@...ey.se
To: musl@...ts.openwall.com
Subject: Re: for information, gcc-4.2.3 miscompiles musl math

On Sat, Nov 21, 2015 at 09:03:42PM +0100, Szabolcs Nagy wrote:
> > Hmm, which places does it add the stores around? Could you fix it with
> > an explicit conversion to double_t? That might be nice to harden
> > against broken compilers without penalizing correct ones.
> 
> yeah that might work
> 
> i dont have gcc-4.2, can you try:
> 
> diff --git a/src/math/__rem_pio2.c b/src/math/__rem_pio2.c
> index a40db9f..d403f81 100644
> --- a/src/math/__rem_pio2.c
> +++ b/src/math/__rem_pio2.c
> @@ -118,7 +118,7 @@ int __rem_pio2(double x, double *y)
>  	if (ix < 0x413921fb) {  /* |x| ~< 2^20*(pi/2), medium size */
>  medium:
>  		/* rint(x/(pi/2)), Assume round-to-nearest. */
> -		fn = x*invpio2 + toint - toint;
> +		fn = (double_t)x*invpio2 + toint - toint;
>  		n = (int32_t)fn;
>  		r = x - fn*pio2_1;
>  		w = fn*pio2_1t;  /* 1st round, good to 85 bits */

Sure, the result:

sin(8.000000) = 0.989358

Which is the same as produced by musl-1.0.0+, without this patch,
iow the expected "good" value.

Thanks!

Rune

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.