[Bug 284905] __builtin_powf produces incorrect result on FreeBSD

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 19 Feb 2025 19:46:58 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=284905

Dimitry Andric <dim@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dim@FreeBSD.org

--- Comment #1 from Dimitry Andric <dim@FreeBSD.org> ---
The builtins seem to be behaving identically across clang and gcc:

  $ cat powtest.c
  #include <math.h>
  #include <stdio.h>

  int main(void)
  {
    float result = powf(10.0f, 11.0f);
    printf("result=%f (%g / %a)\n", result, result, result);
    return 0;
  }

  $ clang -O1 powtest.c -o powtest-clang

  $ ./powtest-clang
  result=99999997952.000000 (1e+11 / 0x1.74876ep+36)

  $ gcc -O1 powtest.c -o powtest-gcc

  $ ./powtest-gcc
  result=99999997952.000000 (1e+11 / 0x1.74876ep+36)

  Compare to when -fno-builtin is used:

  $ clang -fno-builtin -O1 powtest.c -o powtest-clang -lm

  $ ./powtest-clang
  result=100000006144.000000 (1e+11 / 0x1.74877p+36)

  $ gcc -fno-builtin -O1 powtest.c -o powtest-gcc -lm

  $ ./powtest-gcc
  result=100000006144.000000 (1e+11 / 0x1.74877p+36)

Hence, the problem seems to be in libm, not in the compiler builtins.

-- 
You are receiving this mail because:
You are the assignee for the bug.