[gnu.g++.bug] program gets fatal signal on sparc

schmidt%crimee.ics.uci.edu@ORION.CF.UCI.EDU ("Douglas C. Schmidt") (10/05/88)

Hi,

  The following short program gets a segmentation fault on the sparc
for g++ 1.27:

----------------------------------------
#include <stream.h>

const int Max_Buf = 1000;

class foo {
private:
   int j;
   int k;
   static int *Head, *Ptr;

public:
   foo(int i) {
      j = k = i;
   }
   int Return(void) {
      return(j * k);
   }
   void * operator new(long Size) {
      if (!Head) {
         Ptr = Head = (int *) new int(Size * Max_Buf);
      }
      cout << Size << "\n";
   }
};

main() {
   foo Bar(1);
   foo *Bard = new foo(2);

   cout << "Bar.Return() = " << Bar.Return() << "\n";
   cout << "Bard.->Return() = " << Bard->Return() << "\n";   
}
----------------------------------------

Here's the diagnostic:
g++ version 1.27.0
 echo use .cc filename extension!
use .cc filename extension!
 /usr/public/lib/g++/gcc-cpp+ -v -I/cd/ua/schmidt/include/ -undef -D__GNU__ -D__GNUG__ -Dsparc -Dsun -Dunix new.C /tmp/cca24719.cpp
GNU CPP version 1.27.0
 /usr/public/lib/g++/gcc-c++ /tmp/cca24719.cpp -quiet -dumpbase new.C -fchar-charconst -noreg -version -o /tmp/cca24719.s

In function void *foo::operator new (long int):
new.C:20: Segmentation violation
/usr/public/g++: Program c++ got fatal signal 11.
----------------------------------------

Doug