This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug preprocessor/15642] New: NAN Is Not a Constant Because __APPLE_CC__ is Not Defined (OK in Apple 3.3.0)


The following code give "error: initializer element is not constant" with gcc 3.4.0 in C99 mode on 
OSX 10.3.3.  It compiled as expected with gcc 3.3 from Apple's X-Code 1.2.  Section 7.12[5] of the C99 
spec says that NAN expands to a constant expression.

#include <math.h>
	const volatile static float arg2_float_23 = NAN;

    Similar results when I hard-coded the path to the 3.4.0 version of math.h; session below, and I'll 
attach the preprocessed file, which did indeed fail to define NAN as a constant.
    The problem seems to be that __APPLE_CC__ is no longer defined in 3.4.0 (though __APPLE__ still is); 
but the math.h with 3.4.0 (built from the gnu sources) still depends on it:

#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)
#define NAN		__builtin_nanf("0x7fc00000") /* Constant expression, can be used as initializer. */
#else
#define NAN		__nan( )
#endif

    Adding "-D__APPLE_CC__=1642" to the command line worked around the problem.

    Here are the diffs between the predefined macros in the two versions; the other ones look fairly 
innocuous, except perhaps for __GXX_ABI_VERSION, which I don't understand.

3d2
< #define __APPLE_CC__ 1640
10a10,11
> #define __DBL_HAS_INFINITY__ 1
> #define __DBL_HAS_QUIET_NAN__ 1
24a26,27
> #define __FLT_HAS_INFINITY__ 1
> #define __FLT_HAS_QUIET_NAN__ 1
33c36
< #define __GNUC_MINOR__ 3
---
> #define __GNUC_MINOR__ 4
36c39
< #define __GXX_ABI_VERSION 102
---
> #define __GXX_ABI_VERSION 1002
40a44,45
> #define __LDBL_HAS_INFINITY__ 1
> #define __LDBL_HAS_QUIET_NAN__ 1
63c68
< #define __VERSION__ "3.3 20030304 (Apple Computer, Inc. build 1640)"
---
> #define __VERSION__ "3.4.0"


- - -


 /usr/local/gcc34/bin/gcc -std=c99 -pedantic -lmx -funsigned-char -v -save-temps  -c ../c/noerror/
bugfiles/gcc_bugfiles/warn/NAN_not_const-full-path.c
Reading specs from /usr/local/gcc34/lib/gcc/powerpc-apple-darwin7.3.0/3.4.0/specs
Configured with: configure --prefix=/usr/local/gcc34
Thread model: posix
gcc version 3.4.0
 /usr/local/gcc34/libexec/gcc/powerpc-apple-darwin7.3.0/3.4.0/cc1 -E -quiet -v -D__DYNAMIC__ ../
c/noerror/bugfiles/gcc_bugfiles/warn/NAN_not_const-full-path.c -fPIC -std=c99 -pedantic 
-funsigned-char -o NAN_not_const-full-path.i
ignoring nonexistent directory "/usr/local/gcc34/lib/gcc/powerpc-apple-darwin7.3.0/3.4.0/../../../../
powerpc-apple-darwin7.3.0/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/gcc34/include
 /usr/local/gcc34/lib/gcc/powerpc-apple-darwin7.3.0/3.4.0/include
 /usr/include
End of search list.
 /usr/local/gcc34/libexec/gcc/powerpc-apple-darwin7.3.0/3.4.0/cc1 -fpreprocessed NAN_not_const-
full-path.i -fPIC -quiet -dumpbase NAN_not_const-full-path.c -auxbase NAN_not_const-full-path 
-pedantic -std=c99 -version -funsigned-char -o NAN_not_const-full-path.s
GNU C version 3.4.0 (powerpc-apple-darwin7.3.0)
        compiled by GNU C version 3.3 20030304 (Apple Computer, Inc. build 1495).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
../c/noerror/bugfiles/gcc_bugfiles/warn/NAN_not_const-full-path.c:2: error: initializer element is not 
constant

-- 
           Summary: NAN Is Not a Constant Because __APPLE_CC__ is Not
                    Defined (OK in Apple 3.3.0)
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: preprocessor
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: flash at pobox dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: powerpc-apple-darwin7.3.0/3.4.0
  GCC host triplet: powerpc-apple-darwin7.3.0/3.4.0 (--
                    prefix=/usr/local/gcc34)
GCC target triplet: powerpc-apple-darwin7.3.0/3.4.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15642


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]