public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/15642] New: NAN Is Not a Constant Because __APPLE_CC__ is Not Defined (OK in Apple 3.3.0)
@ 2004-05-25 22:19 flash at pobox dot com
  2004-05-25 23:31 ` [Bug target/15642] " pinskia at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 11+ messages in thread
From: flash at pobox dot com @ 2004-05-25 22:19 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2006-01-19 17:18 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-15642-8581@http.gcc.gnu.org/bugzilla/>
2006-01-19 17:18 ` [Bug target/15642] NAN Is Not a Constant Because __APPLE_CC__ is Not Defined (OK in Apple 3.3.0) pinskia at gcc dot gnu dot org
2006-01-19 17:18 ` pinskia at gcc dot gnu dot org
2004-05-25 22:19 [Bug preprocessor/15642] New: " flash at pobox dot com
2004-05-25 23:31 ` [Bug target/15642] " pinskia at gcc dot gnu dot org
2004-05-25 23:43 ` pinskia at gcc dot gnu dot org
2004-05-26  2:59 ` flash at pobox dot com
2004-05-28 17:36 ` pinskia at gcc dot gnu dot org
2005-05-27  0:01 ` pinskia at gcc dot gnu dot org
2005-07-26  4:09 ` pinskia at gcc dot gnu dot org
2005-07-26 23:58 ` pinskia at gcc dot gnu dot org
2005-07-27  0:47 ` pinskia at gcc dot gnu dot org
2005-08-09 18:12 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).