提交 73c870ed 编写于 作者: S Szabolcs Nagy

math: fix aliasing violation in long double wrappers

modfl and sincosl were passing long double* instead of double*
to the wrapped double precision functions (on archs where long
double and double have the same size).
This is fixed now by using temporaries (this is not optimized
to a single branch so the generated code is a bit bigger).
Found by Morten Welinder.
上级 6fbdeff0
......@@ -3,7 +3,12 @@
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double modfl(long double x, long double *iptr)
{
return modf(x, (double *)iptr);
double d;
long double r;
r = modf(x, &d);
*iptr = d;
return r;
}
#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
#if LDBL_MANT_DIG == 64
......
......@@ -4,7 +4,10 @@
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
void sincosl(long double x, long double *sin, long double *cos)
{
sincos(x, (double *)sin, (double *)cos);
double sind, cosd;
sincos(x, &sind, &cosd);
*sin = sind;
*cos = cosd;
}
#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
void sincosl(long double x, long double *sin, long double *cos)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册