whitcomb@EROS.BERKELEY.EDU (Gregg Whitcomb) (03/29/89)
version: 1.34.1 example: #include "stream.h" class c; class xx; class b { int y; int x; b(int j, int i = 9) {y = j; x = i;} void print() {cout << x << "\n";} friend xx; }; class c : public b { c(int i = 1) : (5,i) {} void print() { b::print(); } friend void m(); }; void m() { c a; a.print(); c* e; e = new c(); e->print(); } main() { m(); } % g++ -g testinit.cc % a.out 0 0 ------------------- if class b was a friend of class c, this program works correctly. As is, an error or warning should be generated but is not.
coleman@bert.dg.com (Kim Coleman) (04/04/89)
// Bug with function call parameters in g++ 1.34.1 // // Declaring a class method with a function call default parameter seems to // cause subsequent confusion when compiling the completion of the method. // In the program below, the compiler will hang if there are errors in the // body of annoying::problem. I've hung it with syntax errors, semantic // errors, and warnings (in particular, assignment of a constant pointer to // a non-constant pointer). Related error messages are not printed out. // Only a default parameter value that is a function call seems to provoke // this behavior. As long as you write perfect programs, all is well! :-) // // Older revs of the compiler (pre-1.34) hung up whether or not there were // errors (or even statements) in the function body. // int foo(); class annoying { public: void problem( int position = foo() ); }; void annoying::problem( int position ) { int i; i = unknown; // will cause compiler to hang i=; // so will this int* p; const int* cp; p = cp; // and this } ---------------------- Kim Coleman Data General Corp., Research Triangle Park, NC {the world}!mcnc!rti!dg-rtp!coleman