[gnu.g++.bug] g++ 1.34.0 bug with -g

coleman@bert.dg.com (Kim Coleman) (03/18/89)

The following program was once String.h out of our versio of OOPS. It causes
g++ V1.34.0 to get a segmentation violation when compiled with -g. I'm using
g++ configured for SUN3. Compilation trace follows program

//
// This class declaration will cause a segmentation violation in g++ 1.34
// IF compiled with the -g option. The problem goes away if <problem> is 
// not overloaded, if one of the overloads is not a friend, if the friend'ly
// overload isn't inlined, or if you don't compile with -g. Once upon a
// time, this was String.h out of the OOPs library, and <problem> was an
// operator of SubString.
//

class SubString {
	char* sp;		// substring pointer 
        unsigned sl;		// substring length 
public:
	SubString();
                                            // can't take this out
	void problem(const char* cs);
                                             // this must be inlined and
                                             // must overload above func
                                             // must also be a friend
	friend void problem(const int& i) {}

};

g++ version 1.34.0
 /pdd/pde2/gnu/test/usr/local/lib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -Dmc68020 String.cc /tmp/cca03222.cpp
GNU CPP version 1.34
 /pdd/pde2/gnu/test/usr/local/lib/gcc-c++ /tmp/cca03222.cpp -quiet -dumpbase main.cc -noreg -version -G -o /tmp/cca03222.s
GNU C++ version 1.34.0 (68k, MIT syntax) compiled by GNU C version 1.34.
In function void problem (const int &):
String.cc:19: Segmentation violation
Program c++ got fatal signal 11

----------------------------------------
Kim Coleman                             {the world}!mcnc!rti!dg-rtp!coleman
Data General, Research Triangle Park, NC