NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

standards/40695: C99 violation: Macro NAN in /usr/include/math.h in not constant.



>Number:         40695
>Category:       standards
>Synopsis:       C99 violation: Macro NAN in /usr/include/math.h in not 
>constant.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    standards-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 19 22:00:00 +0000 2009
>Originator:     Jochen Kunz
>Release:        5.0_RC1
>Organization:
The NetBSD Foundation
>Environment:
NetBSD MissSophie 5.0_RC1 NetBSD 5.0_RC1 (MissSophie) #19: Thu Feb 12 22:24:31 
CET 2009  jkunz@MissSophie:/usr/src/build/MissSophie i386
>Description:
The macro NAN (Not A Number) in /usr/include/math.h expands to a variable and 
is not constant.

C99 (http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf), section 7.12.5 
"Mathematics <math.h>", page 213 requires:

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.


>How-To-Repeat:
The folowing program fails to compile:

#include <stdlib.h>
#include <stdio.h>
#include <math.h>

double f1 = NAN;

int
main(int argc, char** argv) {
        printf( "NAN: %f\n", f1);
        exit( EXIT_SUCCESS);
}
>Fix:



Home | Main Index | Thread Index | Old Index