Problem with 2d complex double array

Hi,

the following code compiles fine with gcc 5.2, but does not with pgi 17.7 (using PGI_LOCALRC=/opt/pgi/linux86-64/17.7/bin/localrc.50200, i.e. pgi with gcc 5.2 compatibility):

  const int N = 5;
  std::complex<double> M[N][N];
  for(int i=0;i<N;++i){
    for(int j=0;j<N;++j){
      M[i][j] = 1.;
    }
  }

The compiler output is:

"/opt/pgi/linux86-64/17.7/bin/pgc++" -fastsse --c++11 -Minform=warn -o pgi_vs_gcc.C
PGCC-S-0073-Too many initializers for M (pgi_vs_gcc.C: 15)
PGCC/x86 Linux 17.7-0: compilation completed with severe errors

where line 15 corresponds to the statement std::complex M[N][N];

However, using double instead of complex neither gcc nor pgi complains. Also, not setting PGI_LOCALRC and using compatibility with a older version of gcc works.

Is this example not compliant with the standard or is it a compiler bug or anything else I am doing wrong?

Thanks,
LS[/code]

I need a whole program. I do not see the point of guessing how you
filled in the area around the code fragment you sent.


In addition, I need to know what the default gcc is on your system, and
see the output dialog of
g++ -std=c++11 -v foo.cpp -c

then run it with the 5.2 g++

g++ -std=c++11 -v pgi_vs_gcc.cpp -c
then I want to see the output dialog

pgc++ -std=c++11 -v pgi_vs_gcc.cpp -c



It looks like you used “addlocalrc”. Did you originally
install the PGI compilers with a “Network Install”? If not,
using other gcc compilers for addlocalrc generated localrc will fail.

dave

The whole program is

#include <complex>

int main(){
  const int N = 5;
  std::complex<double> M[N][N];
  for(int i=0;i<N;++i){
    for(int j=0;j<N;++j){
      M[i][j] = 1.;
    }
  } 
  return 0;
}

The output of the system compiler:

/usr/bin/g++ -std=c++11 -v foo.cpp -c
g++: foo.cpp: No such file or directory
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)

The same output from 5.2 g++:

/depot/qsc/QSCN/GCC/bin/g++ -std=c++11 -v foo.cpp -c
g++: error: foo.cpp: No such file or directory
Using built-in specs.
COLLECT_GCC=/depot/qsc/QSCN/GCC/bin/g++
Target: x86_64-redhat-linux
Configured with: /remote/depotsrc/depotsrc/src/gcc-5.2.0/configure --prefix=/depot/gcc-5.2.0 --enable-bootstrap --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,fortran --disable-libgcj --with-cpu=generic --build=x86_64-redhat-linux
Thread model: posix
gcc version 5.2.0 (GCC)

Output of 5.2 g++ compiling the demo program:

/depot/qsc/QSCN/GCC/bin/g++ -std=c++11 -v pgi_vs_gcc.C -c
Using built-in specs.                                                                                             
COLLECT_GCC=/depot/qsc/QSCN/GCC/bin/g++                                                                           
Target: x86_64-redhat-linux                                                                                       
Configured with: /remote/depotsrc/depotsrc/src/gcc-5.2.0/configure --prefix=/depot/gcc-5.2.0 --enable-bootstrap --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,fortran --disable-libgcj --with-cpu=generic --build=x86_64-redhat-linux                                                                                                                    
Thread model: posix                                                                                                                               
gcc version 5.2.0 (GCC)                                                                                                                           
COLLECT_GCC_OPTIONS='-std=c++11' '-v' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64'                                                      
 /depotbld/RHEL6.6/gcc-5.2.0/bin/../libexec/gcc/x86_64-redhat-linux/5.2.0/cc1plus -quiet -v -iprefix /depotbld/RHEL6.6/gcc-5.2.0/bin/../lib/gcc/x86_64-redhat-linux/5.2.0/ -D_GNU_SOURCE pgi_vs_gcc.C -quiet -dumpbase pgi_vs_gcc.C -mtune=generic -march=x86-64 -auxbase pgi_vs_gcc -std=c++11 -version -o /tmp/cccjaIFa.s
GNU C++11 (GCC) version 5.2.0 (x86_64-redhat-linux)
        compiled by GNU C version 5.2.0, GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/depotbld/RHEL6.6/gcc-5.2.0/bin/../lib/gcc/x86_64-redhat-linux/5.2.0/../../../../x86_64-redhat-linux/include"
ignoring duplicate directory "/depotbld/RHEL6.6/gcc-5.2.0/bin/../lib/gcc/../../lib/gcc/x86_64-redhat-linux/5.2.0/../../../../include/c++/5.2.0"
ignoring duplicate directory "/depotbld/RHEL6.6/gcc-5.2.0/bin/../lib/gcc/../../lib/gcc/x86_64-redhat-linux/5.2.0/../../../../include/c++/5.2.0/x86_64-redhat-linux"
ignoring duplicate directory "/depotbld/RHEL6.6/gcc-5.2.0/bin/../lib/gcc/../../lib/gcc/x86_64-redhat-linux/5.2.0/../../../../include/c++/5.2.0/backward"
ignoring duplicate directory "/depotbld/RHEL6.6/gcc-5.2.0/bin/../lib/gcc/../../lib/gcc/x86_64-redhat-linux/5.2.0/include"
ignoring nonexistent directory "/usr/local/include"
ignoring duplicate directory "/depotbld/RHEL6.6/gcc-5.2.0/bin/../lib/gcc/../../lib/gcc/x86_64-redhat-linux/5.2.0/include-fixed"
ignoring nonexistent directory "/depotbld/RHEL6.6/gcc-5.2.0/bin/../lib/gcc/../../lib/gcc/x86_64-redhat-linux/5.2.0/../../../../x86_64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /depotbld/RHEL6.6/gcc-5.2.0/bin/../lib/gcc/x86_64-redhat-linux/5.2.0/../../../../include/c++/5.2.0
 /depotbld/RHEL6.6/gcc-5.2.0/bin/../lib/gcc/x86_64-redhat-linux/5.2.0/../../../../include/c++/5.2.0/x86_64-redhat-linux
 /depotbld/RHEL6.6/gcc-5.2.0/bin/../lib/gcc/x86_64-redhat-linux/5.2.0/../../../../include/c++/5.2.0/backward
 /depotbld/RHEL6.6/gcc-5.2.0/bin/../lib/gcc/x86_64-redhat-linux/5.2.0/include
 /depotbld/RHEL6.6/gcc-5.2.0/bin/../lib/gcc/x86_64-redhat-linux/5.2.0/include-fixed
 /depotbld/RHEL6.6/gcc-5.2.0/bin/../lib/gcc/../../include
 /usr/include
End of search list.
GNU C++11 (GCC) version 5.2.0 (x86_64-redhat-linux)
        compiled by GNU C version 5.2.0, GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 148669ea0437b43fda2169e63e13c18f
COLLECT_GCC_OPTIONS='-std=c++11' '-v' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 as -v --64 -o pgi_vs_gcc.o /tmp/cccjaIFa.s
GNU assembler version 2.25 (x86_64-redhat-linux) using BFD version (GNU Binutils) 2.25
COMPILER_PATH=/depotbld/RHEL6.6/gcc-5.2.0/bin/../libexec/gcc/x86_64-redhat-linux/5.2.0/:/depotbld/RHEL6.6/gcc-5.2.0/bin/../libexec/gcc/
LIBRARY_PATH=/depotbld/RHEL6.6/gcc-5.2.0/bin/../lib/gcc/x86_64-redhat-linux/5.2.0/:/depotbld/RHEL6.6/gcc-5.2.0/bin/../lib/gcc/:/depotbld/RHEL6.6/gcc-5.2.0/bin/../lib/gcc/x86_64-redhat-linux/5.2.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/depotbld/RHEL6.6/gcc-5.2.0/bin/../lib/gcc/x86_64-redhat-linux/5.2.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-std=c++11' '-v' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64'

Output of 17.7 pgc++ compiling demo program:

/opt/pgi/linux86-64/17.7/bin/pgc++ -std=c++11 -v pgi_vs_gcc.C -c
Export PGI=/opt/pgi

/opt/pgi/linux86-64/17.7/bin/pggpp1 --llalign -Dunix -D__unix -D__unix__ -Dlinux -D__linux -D__linux__ -D__NO_MATH_INLINES -D__LP64__ -D__x86_64 -D__x86_64__ -D__LONG_MAX__=9223372036854775807L '-D__SIZE_TYPE__=unsigned long int' '-D__PTRDIFF_TYPE__=long int' -D__THROW= -D__extension__= -D__amd_64__amd64__ -D__k8 -D__k8__ -D__SSE__ -D__MMX__ -D__SSE2__ -D__SSE3__ -D__SSSE3__ -D__STDC_HOSTED__ -D__PGI -D_GNU_SOURCE -D_PGCG_SOURCE -I- -I/opt/pgi/linux86-64/17.7/include-gcc50 -I/opt/pgi/linux86-64/17.7/include -I/depotbld/RHEL6.6/gcc-5.2.0/include/c++/5.2.0 -I/depotbld/RHEL6.6/gcc-5.2.0/include/c++/5.2.0/x86_64-redhat-linux -I/depotbld/RHEL6.6/gcc-5.2.0/include/c++/5.2.0/backward -I/depotbld/RHEL6.6/gcc-5.2.0/lib/gcc/x86_64-redhat-linux/5.2.0/include -I/depotbld/RHEL6.6/gcc-5.2.0/lib/gcc/x86_64-redhat-linux/5.2.0/include-fixed -I/depotbld/RHEL6.6/gcc-5.2.0/include -I/usr/include --gnu_version=50200 -D__pgnu_vsn=50200 --c++11 --preinclude stdarg.h --preinclude_macros _cplus_macros.h -q -o /tmp/pgc++svFM2D9W8PlW.il pgi_vs_gcc.C

/opt/pgi/linux86-64/17.7/bin/pggpp2 pgi_vs_gcc.C -opt 1 -x 119 0xa10000 -x 122 0x40 -x 123 0x1000 -x 127 4 -x 127 17 -x 19 0x400000 -x 28 0x40000 -x 120 0x10000000 -x 70 0x8000 -x 122 1 -x 125 0x20000 -quad -x 59 4 -tp haswell -x 120 0x1000 -astype 0 -fn pgi_vs_gcc.C -il /tmp/pgc++svFM2D9W8PlW.il -x 117 0x600 -x 123 0x80000000 -x 123 4 -x 119 0x20 -def __pgnu_vsn=50200 -x 120 0x200000 -x 70 0x40000000 -x 164 0x800000 -y 163 0xc0000000 -x 189 0x10 -y 189 0x4000000 -gnuvsn 50200 -x 69 0x200 -cmdline '+pgc++ /tmp/pgc++svFM2D9W8PlW.il -std=c++11 -v -c' -asm /tmp/pgc++IvFMMmPPyCig.s
PGCC-S-0073-Too many initializers for M (pgi_vs_gcc.C: 15)
PGCC/x86 Linux 17.7-0: compilation completed with severe errors
pgc++-Fatal-cpp2 completed with exit code 1

Unlinking /tmp/pgc++svFM2D9W8PlW.il
Unlinking /tmp/pgc++IvFMMmPPyCig.s
Unlinking /tmp/pgc++YvFMwXYVNTRK.ll

We have used a “Network Install” and so far haven’t run into any comparable issues with our real world code.

Thanks,
LS