The following piece of code, will not build with gcc 3.4.3 or gcc 4.4.1 on the
above SPARC system. It does build on at least some Linux systems. It is
somewhat similar to bug #21057 though that was reported against the C++
compiler g++, rather than gcc. 

It will not build on an Open Solaris system either, but I'll file that as a
separate bug. 

kir...@t2:[~] $ uname -a
SunOS t2 5.10 Generic_141414-02 sun4v sparc SUNW,T5240

kir...@t2:[~] $ cat /etc/release
                       Solaris 10 5/09 s10s_u7wos_08 SPARC
           Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
                        Use is subject to license terms.
                             Assembled 30 March 2009


Fist, it should be noted it builds with the Sun compiler, and executes as
expected, showing _Complex_I is defined. 

kir...@t2:[~] $ /opt/SUNWspro/bin/cc -V simple_complex.c
cc: Sun C 5.9 SunOS_sparc Patch 124867-11 2009/04/30
acomp: Sun C 5.9 SunOS_sparc Patch 124867-11 2009/04/30
ld: Software Generation Utilities - Solaris Link Editors: 5.10-1.496
kir...@t2:[~] $ ./a.out
CYTHON_CCOMPLEX 1

Here's the source code. 

kir...@t2:[~] $ cat simple_complex.c
#include "stdio.h"
#include "complex.h"

#if defined(_Complex_I)
    #define CYTHON_CCOMPLEX 1
#else
    #define CYTHON_CCOMPLEX 0
#endif


#if CYTHON_CCOMPLEX
    typedef double _Complex __pyx_t_double_complex;
#else
    typedef struct { double real, imag; } __pyx_t_double_complex;
#endif


#if CYTHON_CCOMPLEX
    static __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x,
double y) {
      return x + y*(__pyx_t_double_complex)_Complex_I;
      //return 0;
    }
#else
    static __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x,
double y) {
       __pyx_t_double_complex z;
       z.real = x;
       z.imag = y;
       return z;
    }
#endif

int main(int argc, char** argv) {
    printf("CYTHON_CCOMPLEX %d\n", CYTHON_CCOMPLEX);
    return 0;
}


kir...@t2:[~] $ /opt/SUNWspro/bin/cc simple_complex.c
kir...@t2:[~] $ ./a.out
CYTHON_CCOMPLEX 1


Here is the failure with gcc

kir...@t2:[~] $  gcc -v -std=c99 simple_complex.c 
Using built-in specs.
Target: sparc-sun-solaris2.10
Configured with: ../gcc-4.4.1/configure
--prefix=/usr/local/gcc-4.4.1-sun-linker/ --with-as=/usr/ccs/bin/as
--without-gnu-as --with-ld=/usr/ccs/bin/ld --without-gnu-ld
--enable-languages=c,c++,fortran --with-mpfr-include=/usr/local/include
--with-mpfr-lib=/usr/local/lib --with-gmp-include=/usr/local/include
--with-gmp-lib=/usr/local/lib CC=/usr/sfw/bin/gcc CXX=/usr/sfw/bin/g++
Thread model: posix
gcc version 4.4.1 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-std=c99' '-mcpu=v9'

/usr/local/gcc-4.4.1-sun-linker/bin/../libexec/gcc/sparc-sun-solaris2.10/4.4.1/cc1
-quiet -v -iprefix
/usr/local/gcc-4.4.1-sun-linker/bin/../lib/gcc/sparc-sun-solaris2.10/4.4.1/
-D__sparcv8 simple_complex.c -quiet -dumpbase simple_complex.c -mcpu=v9
-auxbase simple_complex -std=c99 -version -o /var/tmp//ccKtOZ4e.s
ignoring nonexistent directory
"/usr/local/gcc-4.4.1-sun-linker/bin/../lib/gcc/sparc-sun-solaris2.10/4.4.1/../../../../sparc-sun-solaris2.10/include"
ignoring duplicate directory
"/usr/local/gcc-4.4.1-sun-linker/bin/../lib/gcc/../../lib/gcc/sparc-sun-solaris2.10/4.4.1/include"
ignoring duplicate directory
"/usr/local/gcc-4.4.1-sun-linker/bin/../lib/gcc/../../lib/gcc/sparc-sun-solaris2.10/4.4.1/include-fixed"
ignoring nonexistent directory
"/usr/local/gcc-4.4.1-sun-linker/bin/../lib/gcc/../../lib/gcc/sparc-sun-solaris2.10/4.4.1/../../../../sparc-sun-solaris2.10/include"
#include "..." search starts here:
#include <...> search starts here:

/usr/local/gcc-4.4.1-sun-linker/bin/../lib/gcc/sparc-sun-solaris2.10/4.4.1/include

/usr/local/gcc-4.4.1-sun-linker/bin/../lib/gcc/sparc-sun-solaris2.10/4.4.1/include-fixed
 /usr/local/include
 /usr/local/gcc-4.4.1-sun-linker/bin/../lib/gcc/../../include
 /usr/include
End of search list.
GNU C (GCC) version 4.4.1 (sparc-sun-solaris2.10)
        compiled by GNU C version 4.4.1, GMP version 4.3.1, MPFR version 2.4.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: e89036b586fe85e82df0096e13fb8898
simple_complex.c: In function ‘__pyx_t_double_complex_from_parts’:
simple_complex.c:20: error: ‘_Complex_I’ undeclared (first use in this
function)
simple_complex.c:20: error: (Each undeclared identifier is reported only once
simple_complex.c:20: error: for each function it appears in.)

I'm somewhat puzzled I can't see any option to attach a file, so I'll put
inline the preprocessed file, generated with: 

kir...@t2:[~] $  gcc -v -save-temps -std=c99 simple_complex.c 

kir...@t2:[~] $ cat simple_complex.i
# 1 "simple_complex.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "simple_complex.c"
# 1 "/usr/include/stdio.h" 1 3 4
# 20 "/usr/include/stdio.h" 3 4
#pragma ident "@(#)stdio.h      1.84    04/09/28 SMI"

# 1
"/usr/local/gcc-4.4.1-sun-linker/bin/../lib/gcc/sparc-sun-solaris2.10/4.4.1/include-fixed/sys/feature_tests.h"
1 3 4
# 18
"/usr/local/gcc-4.4.1-sun-linker/bin/../lib/gcc/sparc-sun-solaris2.10/4.4.1/include-fixed/sys/feature_tests.h"
3 4
#pragma ident "@(#)feature_tests.h      1.25    07/02/02 SMI"

# 1 "/usr/include/sys/ccompile.h" 1 3 4
# 9 "/usr/include/sys/ccompile.h" 3 4
#pragma ident "@(#)ccompile.h   1.2     04/11/08 SMI"
# 21
"/usr/local/gcc-4.4.1-sun-linker/bin/../lib/gcc/sparc-sun-solaris2.10/4.4.1/include-fixed/sys/feature_tests.h"
2 3 4
# 1 "/usr/include/sys/isa_defs.h" 1 3 4
# 9 "/usr/include/sys/isa_defs.h" 3 4
#pragma ident "@(#)isa_defs.h   1.29    08/06/06 SMI"
# 22
"/usr/local/gcc-4.4.1-sun-linker/bin/../lib/gcc/sparc-sun-solaris2.10/4.4.1/include-fixed/sys/feature_tests.h"
2 3 4
# 23 "/usr/include/stdio.h" 2 3 4
# 67 "/usr/include/stdio.h" 3 4
# 1 "/usr/include/iso/stdio_iso.h" 1 3 4
# 32 "/usr/include/iso/stdio_iso.h" 3 4
#pragma ident "@(#)stdio_iso.h  1.8     05/08/16 SMI"


# 1 "/usr/include/sys/va_list.h" 1 3 4
# 16 "/usr/include/sys/va_list.h" 3 4
#pragma ident "@(#)va_list.h    1.15    04/11/19 SMI"
# 99 "/usr/include/sys/va_list.h" 3 4
typedef __builtin_va_list __gnuc_va_list;





typedef __builtin_va_list __va_list;
# 36 "/usr/include/iso/stdio_iso.h" 2 3 4
# 1 "/usr/include/stdio_tag.h" 1 3 4
# 9 "/usr/include/stdio_tag.h" 3 4
#pragma ident "@(#)stdio_tag.h  1.4     04/09/28 SMI"
# 21 "/usr/include/stdio_tag.h" 3 4
typedef struct __FILE __FILE;
# 37 "/usr/include/iso/stdio_iso.h" 2 3 4
# 1 "/usr/include/stdio_impl.h" 1 3 4
# 9 "/usr/include/stdio_impl.h" 3 4
#pragma ident "@(#)stdio_impl.h 1.15    07/03/05 SMI"
# 29 "/usr/include/stdio_impl.h" 3 4
struct __FILE
{




 int _cnt;
 unsigned char *_ptr;

 unsigned char *_base;
 unsigned char _flag;
 unsigned char _file;

 unsigned __orientation:2;
 unsigned __ionolock:1;
 unsigned __seekable:1;
 unsigned __extendedfd:1;
 unsigned __xf_nocheck:1;
 unsigned __filler:10;
};
# 38 "/usr/include/iso/stdio_iso.h" 2 3 4
# 74 "/usr/include/iso/stdio_iso.h" 3 4
typedef __FILE FILE;







typedef unsigned int size_t;




typedef long fpos_t;
# 146 "/usr/include/iso/stdio_iso.h" 3 4
extern __FILE __iob[20];
# 189 "/usr/include/iso/stdio_iso.h" 3 4
extern int remove(const char *);
extern int rename(const char *, const char *);
extern FILE *tmpfile(void);
extern char *tmpnam(char *);
extern int fclose(FILE *);
extern int fflush(FILE *);
extern FILE *fopen(const char *restrict, const char *restrict);
extern FILE *freopen(const char *restrict,
   const char *restrict, FILE *restrict);
extern void setbuf(FILE *restrict, char *restrict);
extern int setvbuf(FILE *restrict, char *restrict, int,
   size_t);

extern int fprintf(FILE *restrict, const char *restrict, ...);

extern int fscanf(FILE *restrict, const char *restrict, ...);

extern int printf(const char *restrict, ...);

extern int scanf(const char *restrict, ...);

extern int sprintf(char *restrict, const char *restrict, ...);

extern int sscanf(const char *restrict,
   const char *restrict, ...);
extern int vfprintf(FILE *restrict, const char *restrict,
   __va_list);
extern int vprintf(const char *restrict, __va_list);
extern int vsprintf(char *restrict, const char *restrict,
   __va_list);
extern int fgetc(FILE *);
extern char *fgets(char *restrict, int, FILE *restrict);
extern int fputc(int, FILE *);
extern int fputs(const char *restrict, FILE *restrict);


extern int getc(FILE *);
extern int putc(int, FILE *);



extern int getchar(void);
extern int putchar(int);

extern char *gets(char *);
extern int puts(const char *);
extern int ungetc(int, FILE *);
extern size_t fread(void *restrict, size_t, size_t,
 FILE *restrict);
extern size_t fwrite(const void *restrict, size_t, size_t,
 FILE *restrict);

extern int fgetpos(FILE *restrict, fpos_t *restrict);
extern int fsetpos(FILE *, const fpos_t *);

extern int fseek(FILE *, long, int);
extern long ftell(FILE *);
extern void rewind(FILE *);


extern void clearerr(FILE *);
extern int feof(FILE *);
extern int ferror(FILE *);

extern void perror(const char *);


extern int __filbuf(FILE *);
extern int __flsbuf(int, FILE *);
# 68 "/usr/include/stdio.h" 2 3 4
# 136 "/usr/include/stdio.h" 3 4
# 1 "/usr/include/iso/stdio_c99.h" 1 3 4
# 20 "/usr/include/iso/stdio_c99.h" 3 4
#pragma ident "@(#)stdio_c99.h  1.2     04/03/29 SMI"
# 54 "/usr/include/iso/stdio_c99.h" 3 4
extern int vfscanf(FILE *restrict, const char *restrict, __va_list);
extern int vscanf(const char *restrict, __va_list);
extern int vsscanf(const char *restrict, const char *restrict,
  __va_list);
# 68 "/usr/include/iso/stdio_c99.h" 3 4
extern int snprintf(char *restrict, size_t, const char *restrict,
 ...);
extern int vsnprintf(char *restrict, size_t, const char *restrict,
 __va_list);
# 137 "/usr/include/stdio.h" 2 3 4
# 198 "/usr/include/stdio.h" 3 4
extern unsigned char _sibuf[], _sobuf[];
# 230 "/usr/include/stdio.h" 3 4
extern unsigned char *_bufendtab[];
extern FILE *_lastbuf;
# 2 "simple_complex.c" 2
# 1 "/usr/include/complex.h" 1 3 4
# 9 "/usr/include/complex.h" 3 4
#pragma ident "@(#)complex.h    1.9     04/10/23 SMI"
# 24 "/usr/include/complex.h" 3 4
extern float cabsf(float _Complex);
extern float cargf(float _Complex);
extern float cimagf(float _Complex);
extern float crealf(float _Complex);
extern float _Complex cacosf(float _Complex);
extern float _Complex cacoshf(float _Complex);
extern float _Complex casinf(float _Complex);
extern float _Complex casinhf(float _Complex);
extern float _Complex catanf(float _Complex);
extern float _Complex catanhf(float _Complex);
extern float _Complex ccosf(float _Complex);
extern float _Complex ccoshf(float _Complex);
extern float _Complex cexpf(float _Complex);
extern float _Complex clogf(float _Complex);
extern float _Complex conjf(float _Complex);
extern float _Complex cpowf(float _Complex, float _Complex);
extern float _Complex cprojf(float _Complex);
extern float _Complex csinf(float _Complex);
extern float _Complex csinhf(float _Complex);
extern float _Complex csqrtf(float _Complex);
extern float _Complex ctanf(float _Complex);
extern float _Complex ctanhf(float _Complex);

extern double cabs(double _Complex);
extern double carg(double _Complex);
extern double cimag(double _Complex);
extern double creal(double _Complex);
extern double _Complex cacos(double _Complex);
extern double _Complex cacosh(double _Complex);
extern double _Complex casin(double _Complex);
extern double _Complex casinh(double _Complex);
extern double _Complex catan(double _Complex);
extern double _Complex catanh(double _Complex);
extern double _Complex ccos(double _Complex);
extern double _Complex ccosh(double _Complex);
extern double _Complex cexp(double _Complex);


# 61 "/usr/include/complex.h" 3 4
#pragma redefine_extname clog __clog
# 61 "/usr/include/complex.h" 3 4





extern double _Complex clog(double _Complex);
extern double _Complex conj(double _Complex);
extern double _Complex cpow(double _Complex, double _Complex);
extern double _Complex cproj(double _Complex);
extern double _Complex csin(double _Complex);
extern double _Complex csinh(double _Complex);
extern double _Complex csqrt(double _Complex);
extern double _Complex ctan(double _Complex);
extern double _Complex ctanh(double _Complex);

extern long double cabsl(long double _Complex);
extern long double cargl(long double _Complex);
extern long double cimagl(long double _Complex);
extern long double creall(long double _Complex);
extern long double _Complex cacoshl(long double _Complex);
extern long double _Complex cacosl(long double _Complex);
extern long double _Complex casinhl(long double _Complex);
extern long double _Complex casinl(long double _Complex);
extern long double _Complex catanhl(long double _Complex);
extern long double _Complex catanl(long double _Complex);
extern long double _Complex ccoshl(long double _Complex);
extern long double _Complex ccosl(long double _Complex);
extern long double _Complex cexpl(long double _Complex);
extern long double _Complex clogl(long double _Complex);
extern long double _Complex conjl(long double _Complex);
extern long double _Complex cpowl(long double _Complex, long double _Complex);
extern long double _Complex cprojl(long double _Complex);
extern long double _Complex csinhl(long double _Complex);
extern long double _Complex csinl(long double _Complex);
extern long double _Complex csqrtl(long double _Complex);
extern long double _Complex ctanhl(long double _Complex);
extern long double _Complex ctanl(long double _Complex);
# 3 "simple_complex.c" 2
# 12 "simple_complex.c"
    typedef double _Complex __pyx_t_double_complex;






    static __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x,
double y) {
      return x + y*(__pyx_t_double_complex)_Complex_I;

    }
# 32 "simple_complex.c"
int main(int argc, char** argv) {
    printf("CYTHON_CCOMPLEX %d\n", 1);
    return 0;
}


-- 
           Summary: _Complex_I is reported as undeclared. Code builds with
                    Sun compiler.
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: david dot kirkby at onetel dot net
 GCC build triplet: Sun SPARC Enterprise T5240 Server  running Solaris 10
                    05/2009
  GCC host triplet: Sun SPARC Enterprise T5240 Server  running Solaris 10
                    05/2009
GCC target triplet: Sun SPARC Enterprise T5240 Server  running Solaris 10
                    05/2009


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

Reply via email to