g++-4.0s give the following incorrect error on valid code (it should be accepted, I think): gcc4rejectvalid.cc:25: error: 'persistent_object_manager' has not been declared
Run command g++-4.0 -v --save-temps -c gcc4rejectvalid.cc -o gcc4rejectvalid.o Output with version specs: Using built-in specs. Configured with: ../configure --prefix=/sw --prefix=/sw/lib/gcc4 --enable- languages=c,c++,objc,f95,java --infodir=/share/info --with-gmp=/sw --with-as=/sw/lib/odcctools/ bin/as --with-ld=/sw/lib/odcctools/bin/ld --with-included-gettext --host=powerpc-apple-darwin Thread model: posix gcc version 4.0.0 20050130 (experimental) /sw/lib/gcc4/libexec/gcc/powerpc-apple-darwin/4.0.0/cc1plus -E -quiet -v -D__DYNAMIC__ -D__APPLE_CC__=1 gcc4rejectvalid.cc -fPIC -fpch-preprocess -o gcc4rejectvalid.ii ignoring nonexistent directory "/sw/lib/gcc4/lib/gcc/powerpc-apple-darwin/4.0.0/../../../../powerpc- apple-darwin/include" #include "..." search starts here: #include <...> search starts here: /sw/lib/gcc4/lib/gcc/powerpc-apple-darwin/4.0.0/../../../../include/c++/4.0.0 /sw/lib/gcc4/lib/gcc/powerpc-apple-darwin/4.0.0/../../../../include/c++/4.0.0/powerpc-apple- darwin /sw/lib/gcc4/lib/gcc/powerpc-apple-darwin/4.0.0/../../../../include/c++/4.0.0/backward /usr/local/include /sw/lib/gcc4/include /sw/lib/gcc4/lib/gcc/powerpc-apple-darwin/4.0.0/include /usr/include /System/Library/Frameworks /Library/Frameworks End of search list. /sw/lib/gcc4/libexec/gcc/powerpc-apple-darwin/4.0.0/cc1plus -fpreprocessed gcc4rejectvalid.ii -fPIC -quiet -dumpbase gcc4rejectvalid.cc -auxbase-strip gcc4rejectvalid.o -version -o gcc4rejectvalid.s GNU C++ version 4.0.0 20050130 (experimental) (powerpc-apple-darwin) compiled by GNU C version 3.3 20030304 (Apple Computer, Inc. build 1640). GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 gcc4rejectvalid.cc:25: error: 'persistent_object_manager' has not been declared ------------- gcc4rejectvalid.ii --------------- # 1 "gcc4rejectvalid.cc" # 1 "<built-in>" # 1 "<command line>" # 1 "gcc4rejectvalid.cc" namespace util { class persistent_object_manager; namespace memory { class pointer_manipulator { friend class persistent_object_manager; }; } } namespace util { using namespace memory; class persistent_object_manager { static const int foo; }; } namespace util { const int persistent_object_manager::foo = 666; } ---------- end-of-file ------------ Remarks: The above code is accepted by gcc-3.3 and 3.4. The example above was created from a variation of the code reported in PR 19948, and may be closely related. The error goes away when: 1) the first friend declaration is class pointer_manipulator is removed. 2) add a using util::persistent_object_manager; in namespace memory before defining class pointer_manipulator. Workaround: Use 2). (This workaround also applies to PR 19948.) -- Summary: incorrect error: class has not been declared Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: fang at csl dot cornell dot edu CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20234