🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Gordon Joly and Paul Otto Tue, 21 Mar 1989 15:18
Ungracious exit for g++.
#1773
Author: Gordon Joly and Paul Otto
Date: Tue, 21 Mar 1989 15:18
101 lines
4508 bytes
G++ dumps core after reporting an unimplemented construct.  The
following listing was done on a SUN-3/75 running SunOS 3.4, g++ and
libg++ 1.34.0 with config.g++ sun3 on a SUN-3/160 with gcc 1.34.

Script started on Tue Mar 21 14:46:33 1989
io% g++ -v
g++ version 1.34.0
io% g++ -c fib.bug1.cc
fib.bug1.cc:13: sorry, not implemented: initialization of local static object needing constructor
In function struct Integer fib (int):
fib.bug1.cc:17: Segmentation violation
Program c++ got fatal signal 11.
io% ls -l
total 1482
- -rw-------  1 otto          313 Mar 21 08:53 Makefile
- -rw-------  1 otto            0 Mar 21 14:51 bug1
- -rw-r--r--  1 otto      1491770 Mar 21 14:53 core
- -rw-------  1 otto          507 Mar 21 14:51 fib.bug1.cc
- -rw-------  1 otto          507 Mar 21 09:05 fib.cc
- -rw-------  1 otto          375 Mar 21 09:04 runfib.cc
- -rw-------  1 otto         3223 Mar 21 09:01 table.cc
- -rw-------  1 otto         1638 Mar 21 09:02 table.h
io% cat fib.bug1.cc
//
// Example for B11b - of use of tables.
//
// A memo-ising function - using doubly recursive fibonacci as example
//
//                                      G. P. Otto, 1987

#include        "table.h"

Integer
fib(int n)
{
        static table fibresults;                // table of known results

        Integer res = fibresults.lookup(n);     // lookup answer
        if (!fibresults.lastlookupOK){          // if not yet known
                res = (n < 2)? 1 : (fib(n-1) + fib(n-2));       // calculate it
                fibresults.insert(n,res);               // and note the result
        }
        return(res);
}

// PS didn't use "dispose"!
io% cat table.h
//
// a simple "table" class, written for B11b by G. P. Otto, 1987
//
// In this version, the public interface lacks any way of traversing
// the table, so if you don't know what you're looking for, you can't
// find it.
//
// The data-type for "keytype" is almost arbitrary, but you must be able
// to check equality.  (Actually assume that "==" works for keys.)
// IMPORTANT: the hash function needs to be re-designed for some different
// types & frequencies of keys.  (See table.cc)
//

// NEED: declarations for "keytype" & "datumtype" data-types
typedef int     keytype;
#include        <Integer.h>
typedef Integer datumtype;

struct cell {                   // structure to hold data on a linked list
        keytype         key;
        datumtype       datum;
        cell            *next;          // pointer to next cell
};

static const int        hash_tab_size = 97;
                        // hash table size - usually best to make it a prime

class table {
        cell *  list[hash_tab_size];    // each list holds the data whose
                                        //  keys hash to that array index
public:
        table();                        // create an empty table
        ~table();                       // destroy a table, reclaiming
                                        //  space & tidying up as necessary
        void insert(keytype, datumtype);
                                        // "table[key] = ..."
                                        //  overwrite previous entry if 
                                        //  there is one with same key.
                                        //  error message if full.
        datumtype lookup(keytype);      // "... = table[key]"
                                        //  errors (such as no item with
                                        //  specified key, are handled by
                                        //  "lastlookupOK", below.
        int lastlookupOK;               // true if last "lookup" succeeded,
                                        //  false otherwise
        void dispose(keytype);          // delete (key, data) pair from table.
                                        //  No-op if there isn't such a pair.
        // Wot! No traversal?
};
io% ^D
script done on Tue Mar 21 14:49:10 1989

------- End of Forwarded Message
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