![]() |
|
Message-ID: <CABqyc3yHSTm7jBy0SLBxrwtmxH=Q+4t_V051xM6yneev5ptdLw@mail.gmail.com> Date: Tue, 11 Mar 2025 17:19:26 +0100 From: Victor Stinner <vstinner@...hon.org> To: Rich Felker <dalias@...c.org> Cc: musl@...ts.openwall.com Subject: Re: Bug in fma(): should return negative zero Hi, On Tue, Mar 11, 2025 at 2:25 PM Rich Felker <dalias@...c.org> wrote: > What archs have you tested it on? I tested on x86-64. > It doesn't happen for me and the general C code looks like it handles > this case correctly, Oh. I can reproduce the issue with my C example on: * Fedora 41: musl 1.2.5-1, musl-gcc version "gcc (GCC) 14.2.1" * Alpine Linux v3.21: musl-1.2.5-r9, gcc version 14.2.0. Example on Fedora: --- $ musl-gcc x.c -o x && ./x fma(+1e-300, -1e-300, +0) = +0 --- The result is wrong (+0), it must be "-0": fma(x, y, z) = (+1e-300) * (-1e-300) + (+0) = -0. Using glibc, I get the correct result (-0): --- $ gcc x.c -o x -lm && ./x fma(+1e-300, -1e-300, +0) = -0 --- Note: when I wrote a reproducer for FreeBSD, I add to trick the clang compiler to prevent it to call fma() at build time. But I didn't need to do it for this musl reproducer (using gcc). I checked using gdb that main() actually calls fma() at runtime: -------- $ gdb ./x (gdb) disassemble main ... 0x0000000000401192 <+76>: call 0x401030 <fma@plt> ... -------- Victor -- Night gathers, and now my watch begins. It shall not end until my death.
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.