rfg@MCC.COM (Ron Guilmette) (04/22/89)
In the following sourec file, G++ 1.35.0 (pre-release) fails to diagnose all of the errors indicated. Also, the error mesages which are produced are confusing in two respects. First, there is the message "In function void _GLOBAL_$I$b037_C ():". Shouldn't that say "At top level"? Also, some of the messages just say "within this context". I guess that these are supposed to be a continuation of the preceeding messages, but it's hard to tell. b037 had missed error(s) as follows: 10: class1 (); // ERROR 32: c1p = new class1; // ERROR 33: c2p = new class2; // ERROR b037: FAILED ------------------------------------------------------------------ // Check that it is illegal to declare or to invoke (explicitly or // implicitly) a "default" constructor for a class type within the // private part of the given class if the given class has no friends. // // Cases: // constructor with no arguments // constructor with all defautable arguments class class1 { class1 (); // ERROR public: class1 (int i); }; class class2 { class2 (int i = 22, int j = 33); // ERROR public: class2 (float f, float g); }; class1 global_class1_object; // ERROR class2 global_class2_object; // ERROR class1* c1p; class2* c2p; int test () { class1 local_class1_object; // ERROR class2 local_class2_object; // ERROR c1p = new class1; // ERROR c2p = new class2; // ERROR c1p = &local_class1_object; // avoid warnings c2p = &local_class2_object; // avoid warnings return 0; } ---------------------------------------------------------------------- /usr/local/src/src/g++/build/sun3/1.35-.0-.0/g++ -B/usr/local/src/src/g++/build/sun3/1.35-.0-.0/ -Wall -Wwrite-strings -S -v b037.C g++ version 1.35.0- /usr/local/src/src/g++/build/sun3/1.35-.0-.0/cpp -+ -v -undef -D__GNU__ -D__GNUG__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -Wall -D__HAVE_68881__ -Dmc68020 b037.C /tmp/cca16019.cpp GNU CPP version 1.35.0- /usr/local/src/src/g++/build/sun3/1.35-.0-.0/c++ /tmp/cca16019.cpp -quiet -dumpbase b037.C -Wall -Wwrite-strings -noreg -version -o b037.s GNU C++ version 1.35.0- (68k, MIT syntax) compiled by GNU C version 1.34.1. In function int test (): b037.C:29: constructor `struct class1 *class1::class1 ()' is private b037.C:16: the constructor struct class2 *class2::class2 (int (= 22 ), int (= 33 )) is private b037.C:30: within this context In function void _GLOBAL_$I$b037_C (): b037.C:21: constructor `struct class1 *class1::class1 ()' is private b037.C:16: the constructor struct class2 *class2::class2 (int (= 22 ), int (= 33 )) is private b037.C:22: within this context