[PATCH 56/59] math: Fix compare sort function on compoundn

Collin Funk collin.funk1@gmail.com
Mon Oct 20 19:30:22 GMT 2025


Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:

> To use the fabs function to the used type, instead of the double
> variant.  it fixes a build issue with clang:
>
> ./s_compoundn_template.c:64:14: error: absolute value function 'fabs' given an argument of type 'const long double' but has parameter of type 'double' which may cause truncation of value [-Werror,-Wabsolute-value]
>    64 |   FLOAT pd = fabs (*(const FLOAT *) p);
>       |              ^
> ./s_compoundn_template.c:64:14: note: use function 'fabsl' instead
>    64 |   FLOAT pd = fabs (*(const FLOAT *) p);
>       |              ^~~~
>       |              fabsl
> ---
>  math/s_compoundn_template.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/math/s_compoundn_template.c b/math/s_compoundn_template.c
> index ddbcc145809..224610ba837 100644
> --- a/math/s_compoundn_template.c
> +++ b/math/s_compoundn_template.c
> @@ -61,8 +61,8 @@ mul3_split (FLOAT *out, FLOAT a, FLOAT b, FLOAT c, FLOAT d)
>  static int
>  compare (const void *p, const void *q)
>  {
> -  FLOAT pd = fabs (*(const FLOAT *) p);
> -  FLOAT qd = fabs (*(const FLOAT *) q);
> +  FLOAT pd = M_FABS (*(const FLOAT *) p);
> +  FLOAT qd = M_FABS (*(const FLOAT *) q);
>    if (pd < qd)
>      return -1;
>    else if (pd == qd)

Looks like that was the intention originally.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>

Collin


More information about the Libc-alpha mailing list