Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Feb 2025 19:46:58 +0000
From:      bugzilla-noreply@freebsd.org
To:        numerics@FreeBSD.org
Subject:   [Bug 284905] __builtin_powf produces incorrect result on FreeBSD
Message-ID:  <bug-284905-18636-Y7xOXE92dv@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-284905-18636@https.bugs.freebsd.org/bugzilla/>
References:  <bug-284905-18636@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D284905

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 =3D powf(10.0f, 11.0f);
    printf("result=3D%f (%g / %a)\n", result, result, result);
    return 0;
  }

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

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

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

  $ ./powtest-gcc
  result=3D99999997952.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=3D100000006144.000000 (1e+11 / 0x1.74877p+36)

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

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

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

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-284905-18636-Y7xOXE92dv>