🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by "Douglas C. Schmidt" Thu, 22 Sep 1988 07:07
G++ 1.27 gets fatal signal on sparc
#1456
Author: "Douglas C. Schmidt"
Date: Thu, 22 Sep 1988 07:07
103 lines
3441 bytes
Hi,

  The following erroneous code produces a fatal signal on Sun Sparc.

----------------------------------------
static const int Default_Range     = 100;  
static const int Default_Size      = 100;  

class Ullman_Array {

private:
   int       Default_Value;
   int       Max_Range;
   int       Max_Size;
   int      *Index_Array;
   int      *Hand_Shake_Array;
   int  *Storage_Array;
   int       Current_Max;

public:

   Ullman_Array(int Array_Range, int Set_Size = 0,) { // here's problem 1
      if (Set_Size == 0) {
         Set_Size = Array_Range;
      }   
      Max_Range        = Array_Range;
      Max_Size         = Set_Size;
      Index_Array      = new int[Max_Range];
      Hand_Shake_Array = new int[Max_Size];
      Storage_Array    = new int[Max_Size];
      Current_Max      = -1;
   }

   Ullman_Array(int Array_Range, int Fill, int Set_Size = 0,) {
      if (Set_Size == 0) {
         Set_Size = Array_Range;
      }
      Default_Value    = Fill;
      Max_Range        = Array_Range;
      Max_Size         = Set_Size;
      Index_Array      = new int[Max_Range];
      Hand_Shake_Array = new int[Max_Size];
      Storage_Array    = new int[Max_Size];
      Current_Max      = -1;
   }

   int& operator[](int Index) { 
   
      int  Hand_Shake_Index = Index_Array[Index];

      if ((Hand_Shake_Index < 0) || (Hand_Shake_Index > Current_Max) || 
          (Index != Hand_Shake_Array[Hand_Shake_Index])) {
         Hand_Shake_Index                   = ++Current_Max;
         Hand_Shake_Array[Hand_Shake_Index] = Index;
         Index_Array[Index]                 = Hand_Shake_Index;
         Storage_Array[Hand_Shake_Index]    = Default_Value;
      }
      return(Storage_Array[Hand_Shake_Index]);
   }

   int Total_Range(void) {
      return (Max_Range);
   }   

   int Total_Size(void) {
      return(Max_Size);
   }   

   int Current_Size(void) {
      return(Current_Max);
   }
};

main(int argc,char *argv[]) {
   int i = atoi(argv[1]);
   int n = i;
   Ullman_Array A(n);

   while (--i) {
      A[i] = rand();
   }
   i = n;
   while (--i) {
      cout << A[i] << "\n";
   }
}
----------------------------------------

and here's the diagnostic:

----------------------------------------
g++ version 1.27.0
 /usr/public/lib/g++/gcc-cpp+ -v -I/cl/ua/schmidt/include/ -undef -D__GNU__ -D__GNUG__ -Dsparc -Dsun -Dunix bug.cc /tmp/cca19709.cpp
GNU CPP version 1.27.0
 /usr/public/lib/g++/gcc-c++ /tmp/cca19709.cpp -quiet -dumpbase bug.cc -fmemoize-lookups -fsave-memoized -fchar-charconst -noreg -version -o /tmp/cca19709.s
bug.cc:17: warning: type specifier omitted for parameter
bug.cc:17: all trailing parameters must have default arguments
bug.cc:29: warning: type specifier omitted for parameter
bug.cc:29: all trailing parameters must have default arguments

bug.cc:72: Segmentation violation
/usr/public/g++: Program c++ got fatal signal 11.
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