Following code is not compiling with g++ 4.2.3, but compiles fine with g++ 3.3.3: ========================== #include<iostream> class mybase { public: virtual int afunc()=0; }; main() { mybase (*ptrs)[10]; } ========================== Error given by g++4.2.3 is as below for the above code. I am using following simple command to compile the command, without any options, flags # g++ testpure.cpp testpure.cpp: In function âint main()â: testpure.cpp:10: error: invalid abstract type âmybaseâ for âptrsâ testpure.cpp:3: note: because the following virtual functions are pure within âmybaseâ: testpure.cpp:5: note: virtual int mybase::afunc() ========================== Information about compiler, OS, Kernel on which I am seeing this issue is as below: (1) Compiler information: g++ -v Using built-in specs. Target: x86_64-unknown-linux-gnu Configured with: ./configure --prefix=/app/devtools/gcc-4.2.3 --exec-prefix=/app/devtools/gcc-4.2.3 --with-mpfr=/app/devtools/mpfr-2.2.1 --with-mpfr-include=/app/devtools/mpfr-2.2.1 --with-mpfr-lib=/app/devtools/mpfr-2.2.1/.libs --with-gmp=/app/devtools/gmp-4.2.2 --with-gmp-include=/app/devtools/gmp-4.2.2 --with-gmp-lib=/app/devtools/gmp-4.2.2/.libs --enable-languages=c,c++,fortran Thread model: posix gcc version 4.2.3
(2) OS Information: cat /etc/SuSE-release SUSE Linux Enterprise Server 10 (x86_64) VERSION = 10 PATCHLEVEL = 1 ------------- uname -a Linux vsgl36a-1031 2.6.16.46-0.12-smp #1 SMP Thu May 17 14:00:09 UTC 2007 x86_64 x86_64 x86_64 GNU/Linux ========================== Can I please know why g++4.2.3 is behaving differently that g++ 3.3.3? According to C++, we can declare the pointer(s) of abstract base class. But why is g++ 4.2.3 compiler not allowing to even declare these pointers? Is this a bug in g++4.2.3? In which release of g++, this bug is fixed? There are many other such deviations we noticed in this compiler from the normal C++ principles. Should we not use g++ 4.2.3? Which is the most stable version in g++ 4.x.x series? Please help. ------------------------------------------ Output of :g++ -v -save-temps testpure.cpp Using built-in specs. Target: x86_64-unknown-linux-gnu Configured with: ./configure --prefix=/app/devtools/gcc-4.2.3 --exec-prefix=/app/devtools/gcc-4.2.3 --with-mpfr=/app/devtools/mpfr-2.2.1 --with-mpfr-include=/app/devtools/mpfr-2.2.1 --with-mpfr-lib=/app/devtools/mpfr-2.2.1/.libs --with-gmp=/app/devtools/gmp-4.2.2 --with-gmp-include=/app/devtools/gmp-4.2.2 --with-gmp-lib=/app/devtools/gmp-4.2.2/.libs --enable-languages=c,c++,fortran Thread model: posix gcc version 4.2.3 /app/devtools/gcc-4.2.3/libexec/gcc/x86_64-unknown-linux-gnu/4.2.3/cc1plus -E -quiet -v -D_GNU_SOURCE testpure.cpp -mtune=generic -fpch-preprocess -o testpure.ii ignoring nonexistent directory "/app/devtools/gcc-4.2.3/lib/gcc/x86_64-unknown-linux-gnu/4.2.3/../../../../x86_64-unknown-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /app/devtools/gcc-4.2.3/lib/gcc/x86_64-unknown-linux-gnu/4.2.3/../../../../include/c++/4.2.3 /app/devtools/gcc-4.2.3/lib/gcc/x86_64-unknown-linux-gnu/4.2.3/../../../../include/c++/4.2.3/x86_64-unknown-linux-gnu /app/devtools/gcc-4.2.3/lib/gcc/x86_64-unknown-linux-gnu/4.2.3/../../../../include/c++/4.2.3/backward /usr/local/include /app/devtools/gcc-4.2.3/include /app/devtools/gcc-4.2.3/lib/gcc/x86_64-unknown-linux-gnu/4.2.3/include /usr/include End of search list. /app/devtools/gcc-4.2.3/libexec/gcc/x86_64-unknown-linux-gnu/4.2.3/cc1plus -fpreprocessed testpure.ii -quiet -dumpbase testpure.cpp -mtune=generic -auxbase testpure -version -o testpure.s GNU C++ version 4.2.3 (x86_64-unknown-linux-gnu) compiled by GNU C version 4.2.3. GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 4f1a9dd65e939519bf89a9e8788cb5ba testpure.cpp: In function âint main()â: testpure.cpp:10: error: invalid abstract type âmybaseâ for âptrsâ testpure.cpp:3: note: because the following virtual functions are pure within âmybaseâ: testpure.cpp:5: note: virtual int mybase::afunc() ====================================================== cat testpure.s .file "testpure.cpp" .section .ctors,"aw",@progbits .align 8 .quad _GLOBAL__I_main -- Summary: g++ compiler giving error for array of pointers of abstract base class Product: gcc Version: 4.2.3 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ganesh dot borse at credit-suisse dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41840