[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
standards/127795: [patch] INFINITY and INF have wrong type
- To: freebsd-gnats-submit_(_at_)_FreeBSD_(_dot_)_org
- Subject: standards/127795: [patch] INFINITY and INF have wrong type
- From: Christoph Mallon <christoph_(_dot_)_mallon_(_at_)_gmx_(_dot_)_de>
- Date: Thu, 2 Oct 2008 07:47:03 GMT
- Cc:
- Resent-date: Thu, 2 Oct 2008 07:50:05 GMT
- Resent-from: FreeBSD-gnats-submit_(_at_)_FreeBSD_(_dot_)_org (GNATS Filer)
- Resent-message-id: <200810020750_(_dot_)_m927o5Bj095447_(_at_)_freefall_(_dot_)_freebsd_(_dot_)_org>
- Resent-reply-to: FreeBSD-gnats-submit_(_at_)_FreeBSD_(_dot_)_org, Christoph Mallon <christoph_(_dot_)_mallon_(_at_)_gmx_(_dot_)_de>
- Resent-to: freebsd-standards_(_at_)_FreeBSD_(_dot_)_org
>Number: 127795
>Category: standards
>Synopsis: [patch] INFINITY and INF have wrong type
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-standards
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Thu Oct 02 07:50:05 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator: Christoph Mallon
>Release: n/a
>Organization:
>Environment:
n/a
>Description:
INFINITY and NAN are defined as __builtin_inf() resp. __builtin_nan(), which both return a double result. But the C99 standard mandates that INFINITY and NAN are of type float (ISO/IEC 9899:1999(E) 7.12 clause 4 and 5).
>How-To-Repeat:
This test program prints "bad" for both INFINITY and NAN:
#include <math.h>
#include <stdio.h>
int main(void)
{
printf("INFINITY %s NAN %s\n",
sizeof(INFINITY) == sizeof(float) ? "good" : "bad",
sizeof(NAN) == sizeof(float) ? "good" : "bad");
return 0;
}
>Fix:
Change the macro definitions to use __builtin_inff() resp. __builtin_nanf(). See attachment.
Patch attached with submission follows:
Index: lib/msun/src/math.h
===================================================================
--- lib/msun/src/math.h (Revision 183225)
+++ lib/msun/src/math.h (Arbeitskopie)
@@ -55,8 +55,8 @@
#ifdef __MATH_BUILTIN_CONSTANTS
#define HUGE_VALF __builtin_huge_valf()
#define HUGE_VALL __builtin_huge_vall()
-#define INFINITY __builtin_inf()
-#define NAN __builtin_nan("")
+#define INFINITY __builtin_inff()
+#define NAN __builtin_nanf("")
#else
#define HUGE_VALF (float)HUGE_VAL
#define HUGE_VALL (long double)HUGE_VAL
>Release-Note:
>Audit-Trail:
>Unformatted:
_______________________________________________
freebsd-standards_(_at_)_freebsd_(_dot_)_org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-standards
To unsubscribe, send any mail to "freebsd-standards-unsubscribe_(_at_)_freebsd_(_dot_)_org"
Visit your host, monkey.org