Date: Fri, 12 Mar 2004 19:41:36 +0100 (CET) From: Stefan Farfeleder <stefan@fafoe.narf.at> To: FreeBSD-gnats-submit@FreeBSD.org Cc: stefan@fafoe.narf.at Subject: standards/64173: C99 requires some <math.h> macros to be constant expressions Message-ID: <20040312184136.CF74D480@wombat.fafoe.narf.at> Resent-Message-ID: <200403121850.i2CIoKP9071680@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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@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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040312184136.CF74D480>