[Bug 294214] clang builtin functions break libm
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 294214] clang builtin functions break libm"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 294214] clang builtin functions break libm"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 294214] clang builtin functions break libm"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 294214] clang builtin functions break libm"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 294214] clang builtin functions break libm"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 294214] clang builtin functions break libm"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 294214] clang builtin functions break libm"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 294214] clang builtin functions break libm"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 294214] clang builtin functions break libm"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 294214] clang builtin functions break libm"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 02 Apr 2026 20:09:56 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=294214
Bug ID: 294214
Summary: clang builtin functions break libm
Product: Base System
Version: CURRENT
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: bin
Assignee: bugs@FreeBSD.org
Reporter: kargl@FreeBSD.org
It has been brought to my attention that the use of some
clang builtin functions break libm. Consider,
#include <math.h>
#include <stdio.h>
int
main(void)
{
double f, x, y;
x = 0.;
y = copysign(x, -1.);
printf("fmax(% lf % lf) = % lf\n", x, x, fmax(x,x));
printf("fmax(% lf % lf) = % lf\n", x, y, fmax(x,y));
printf("fmax(% lf % lf) = % lf\n", y, x, fmax(y,x));
return (0);
}
% cc -o z fmax.c -lm && ./z
fmax( 0.000000 0.000000) = 0.000000
fmax( 0.000000 -0.000000) = 0.000000
fmax(-0.000000 0.000000) = -0.000000 <--- this is wrong
% cc -o z fmax.c -lm -fno-builtin && ./z
fmax( 0.000000 0.000000) = 0.000000
fmax( 0.000000 -0.000000) = 0.000000
fmax(-0.000000 0.000000) = 0.000000
% gcc15 -o z fmax.c -lm && ./z
fmax( 0.000000 0.000000) = 0.000000
fmax( 0.000000 -0.000000) = 0.000000
fmax(-0.000000 0.000000) = 0.000000 <--- this is correct
% -o z fmax.c -lm -fno-builtin && ./z
fmax( 0.000000 0.000000) = 0.000000
fmax( 0.000000 -0.000000) = 0.000000
fmax(-0.000000 0.000000) = 0.000000
The FreeBSD documentation has
% man fmax
...
DESCRIPTION
The fmax(), fmaxf(), and fmaxl() functions return the larger of x and y,
and likewise, the fmin(), fminf(), and fminl() functions return the
smaller of x and y. They treat +0.0 as being larger than -0.0.
--
You are receiving this mail because:
You are the assignee for the bug.