From owner-freebsd-current Thu Oct 31 1:17:27 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1138137B401 for ; Thu, 31 Oct 2002 01:17:25 -0800 (PST) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 041C443E6E for ; Thu, 31 Oct 2002 01:17:24 -0800 (PST) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id UAA21367; Thu, 31 Oct 2002 20:17:12 +1100 Date: Thu, 31 Oct 2002 20:28:33 +1100 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: "M. Warner Losh" Cc: tlambert2@mindspring.com, , , , Subject: Re: Lack of real long double support In-Reply-To: <20021030.170154.35505346.imp@bsdimp.com> Message-ID: <20021031202343.W8632-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 #include 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 majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message