[LLVMbugs] [Bug 6492] New: NAN not a constant

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Mar 4 00:26:10 PST 2010


           Summary: NAN not a constant
           Product: clang
           Version: unspecified
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: enhancement
          Priority: P5
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: holm at liacs.nl
                CC: llvmbugs at cs.uiuc.edu

I have tested this on the clang build distributed with Snow Leopard, so if it
has already been fixed sorry in advance.

Using the NAN macro from math.h results in this diagnostics:

nantest.c:2:11: error: initializer element is not a compile-time constant
float x = NAN;
/usr/include/architecture/i386/math.h:66:25: note: instantiated from:
    #define NAN         __builtin_nanf("0x7fc00000") /* Constant ...
1 diagnostic generated.

where nantest.c contains the following:
#include <math.h>
float x = NAN;

This works fine in GCC, but not in Clang and seem to be in violation of C99

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.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list