standards/64173: C99 requires some <math.h> macros to be constant expressions

Stefan Farfeleder stefan at fafoe.narf.at
Fri Mar 12 10:50:21 PST 2004


>Number:         64173
>Category:       standards
>Synopsis:       C99 requires some <math.h> macros to be constant expressions
>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:   Fri Mar 12 10:50:20 PST 2004
>Closed-Date:
>Last-Modified:
>Originator:     Stefan Farfeleder
>Release:        FreeBSD 5.2-CURRENT i386
>Organization:
>Environment:
System: FreeBSD wombat.fafoe.narf.at 5.2-CURRENT FreeBSD 5.2-CURRENT #16: Tue Mar 2 19:09:53 CET 2004 stefan at wombat.fafoe.narf.at:/usr/home/stefan/freebsd/obj/usr/home/stefan/freebsd/src/sys/WOMBAT i386

>Description:
Quoting from ISO/IEC 9899:1999:

# 7.12 Mathematics <math.h>

# 3 The macro
#           HUGE_VAL
#   expands to a positive double constant expression, not necessarily representable as a
#   float. The macros
#           HUGE_VALF
#           HUGE_VALL
#   are respectively float and long double analogs of HUGE_VAL.191)
# 
# 4 The macro
#            INFINITY
#   expands to a constant expression of type float representing positive or unsigned
#   infinity, if available; else to a positive constant of type float that overflows at
#   translation time.192)
# 
# 5 The macro
#           NAN
#   is defined if and only if the implementation supports quiet NaNs for the float type. It
#   expands to a constant expression of type float representing a quiet NaN.

These macros expand to the variables __infinity and __nan currently (defined in
src/lib/${ARCH}/gen/infinity.c), thus violating the requirement of being
constant expressions.

>How-To-Repeat:
This strictly conformant C99 program fails to compile:

$ cat test.c
#include <math.h>
double d = HUGE_VAL;
int main(void) {}
$ c99 test.c
test.c:2: error: initializer element is not constant

>Fix:
None yet.

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-standards mailing list