On Wed, 30 Oct 2002, M. Warner Losh wrote:
> The one issue that I've seen is
>
> long double a = 1.0L;
> long double b = 1.0L + LDBL_EPSION
> if (a == b) abort();
>
> which is what I'm trying to fix. (note, "1.0L" must be spelled
> "oneld()" and long double oneld() { return (1.0L);}) to avoid the
> optimizer getting it right.
Example of how fixing this breaks a similar assertion for DBL_ESPILON:
%%%
$ cat z.c
#include <float.h>
#include <floatingpoint.h>
long double oneld = 1.0L;
double oned = 1.0;
int
main()
{
test(2);
test(3);
}
int
test(int prec)
{
long double la, lb;
double a, b;
fpsetprec(prec);
la = oneld;
lb = oneld + LDBL_EPSILON;
if (la == lb)
printf("LDBL_EPSILON failed test 1 with prec %d\n", prec);
la = oneld;
lb = oneld + LDBL_EPSILON / 2;
if (la != lb)
printf("LDBL_EPSILON failed test 2 with prec %d\n", prec);
a = oned;
b = oned + DBL_EPSILON;
if (a == b)
printf("DBL_EPSILON failed test 1 with prec %d\n", prec);
a = oned;
b = oned + DBL_EPSILON / 2;
if (a != b)
printf("DBL_EPSILON failed test 2 with prec %d\n", prec);
}
$ cc -o z z.c
$ ./z
LDBL_EPSILON failed test 1 with prec 2
$ cc -O -o z z.c.
$ ./z
LDBL_EPSILON failed test 1 with prec 2
DBL_EPSILON failed test 2 with prec 3
%%%
The full brokenness only shows up with -O.
Bruce
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message