🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by "Douglas C. Schmidt" Wed, 05 Oct 1988 03:37
program gets fatal signal on sparc
#1476
Author: "Douglas C. Schmidt"
Date: Wed, 05 Oct 1988 03:37
55 lines
1760 bytes
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads