🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by juraj petras Fri, 21 Aug 1992 17:06
compiler crushes
#979
Author: juraj petras
Date: Fri, 21 Aug 1992 17:06
827 lines
19464 bytes
----------
X-Sun-Data-Type: text
X-Sun-Data-Description: text
X-Sun-Data-Name: text
X-Sun-Content-Lines: 36

Hi,
I need a help.

I tried to run simple program inspired by B. Stroustrup from "The C++ Programing Language" second edition p.260. A non-intrusive list is supposed to stored the pointers to the Dates. I localized that compiler crushed when it compiled
the definition of ilst (SList of Dates). The rest is enclosed in the comment brackets.

 SList<Date> ilst;

Here are the information which should help you to find an error:

I use Sparc station, SunOS + OpenWindows Version 3. I didn't install gcc and
so I don't know the operands for configure command.

All necessary files are included in the file "outfile".


wilkes% gcc -E tSList.cc > outfile
wilkes% gcc -v tSList.cc 
Reading specs from /usr/local/lib/gcc/sparc/2.0/specs
gcc version 2.0
 /usr/local/lib/gcc/sparc/2.0/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix tSList.cc /usr/tmp/cca09086.cpp
GNU CPP version 2.0 (sparc)
 /usr/local/lib/gcc/sparc/2.0/cc1plus /usr/tmp/cca09086.cpp -quiet -dumpbase tSList.cc -version -o /usr/tmp/cca09086.s
GNU C++ version 2.0 (sparc) compiled by GNU C version 2.0.
gcc: Internal compiler error: program cc1plus got fatal signal 11
wilkes% 

Remark:
The intrusive list works perfect using template as is stated a few pages
before in the same book.

I am going use g++ as an implementaion language for my thesis.

Thank you for you help 

Juraj Petras, School of Computer Science, Carleton University, Ottawa
----------
X-Sun-Data-Type: default
X-Sun-Data-Name: outfile
X-Sun-Content-Lines: 734

# 1 "tSList.cc"
# 1 "SList.h" 1
struct SLink {

 	SLink* next;
 	SLink() { next = 0; }
	SLink(SLink* p) { next = p; }
};


template<class TT>
struct TLink : public SLink {
	TT info;
	TLink(const TT& a) : info(a) { }
	~TLink();
};


class SListBase
{
	SLink* last;		 
public:
	int insert(SLink*) ;	 
	int append(SLink*);	 
	SLink* get();		 
	SListBase()	{ last = 0; }
	SListBase(SLink* a) { last = a->next = a; }
};

template<class T> 
class SList : private SListBase 
{
public:
	SList() : SListBase() {}
	~SList();	
	void insert(const T& a) 
		{SListBase::insert(new TLink<T>(a)); }
	void append(const T& a) 
		{SListBase::append(new TLink<T>(a)); }
	T get(){
		TLink<T>* lnk = (TLink<T>*) SListBase::get();
		T i = lnk->info;
		delete lnk;
		return i;
		}
	
};
# 1 "tSList.cc" 2

# 1 "Date.h" 1
# 1 "/usr/local/lib/g++-include/iostream.h" 1 3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 



#pragma interface




# 1 "/usr/local/lib/g++-include/streambuf.h" 1 3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 




#pragma interface


 
# 1 "/usr/local/lib/g++-include/stddef.h" 1 3


extern "C" {



# 1 "/usr/local/lib/gcc/sparc/2.0/include/stddef.h" 1 3






 


 





 














typedef int ptrdiff_t;






 














typedef int size_t;






 
















typedef short unsigned int wchar_t;









 




 





# 7 "/usr/local/lib/g++-include/stddef.h" 2 3




}

# 25 "/usr/local/lib/g++-include/streambuf.h" 2 3
















class ostream; class streambuf;

typedef long streamoff, streampos;

struct _ios_fields {  
    streambuf *_strbuf;
    ostream* _tie;
    long _width;
    unsigned long _flags;
    char _fill;
    unsigned char _state;
    unsigned short _precision;
};





class ios : public _ios_fields {
  public:
    enum io_state { goodbit=0, eofbit=1, failbit=2, badbit=4 };
    enum open_mode {
	in=1,
	out=2,
	ate=4,
	app=8,
	trunc=16,
	nocreate=32,
	noreplace=64 };
    enum seek_dir { beg, cur, end};
    enum { skipws=01, left=02, right=04, internal=010,
	   dec=020, oct=040, hex=0100,
	   showbase=0200, showpoint=0400, uppercase=01000, showpos=02000,
	   scientific=04000, fixed=0100000, unitbuf=020000, stdio=040000,
	   dont_close=0x80000000  
	   };

    ostream* tie() { return _tie; }
    ostream* tie(ostream* val) { ostream* save=_tie; _tie=val; return save; }

     
    char fill() { return _fill; }
    char fill(char newf) { char oldf = _fill; _fill = newf; return oldf; }
    unsigned long flags() { return _flags; }
    unsigned long flags(unsigned long new_val) {
	unsigned long old_val = _flags; _flags = new_val; return old_val; }
    unsigned short precision() { return _precision; }
    unsigned short precision(int newp) {
	unsigned short oldp = _precision; _precision = (unsigned short)newp;
	return oldp; }
    unsigned long setf(unsigned long val) {
	unsigned long oldbits = _flags;
	_flags |= val; return oldbits; }
    unsigned long setf(unsigned long val, unsigned long mask) {
	unsigned long oldbits = _flags;
	_flags = (_flags & ~mask) | (val & mask); return oldbits; }
    unsigned long unsetf(unsigned long mask) {
	unsigned long oldbits = _flags & mask;
	_flags &= ~mask; return oldbits; }
    long width() { return _width; }
    long width(long val) { long save = _width; _width = val; return save; }

    static const unsigned long basefield;
    static const unsigned long adjustfield;
    static const unsigned long floatfield;

    streambuf* rdbuf() { return _strbuf; }
    void clear(int state = 0) { _state = state; }
    int good() { return _state == 0; }
    int eof() { return _state & ios::eofbit; }
    int fail() { return _state & (ios::badbit|ios::failbit); }
    int bad() { return _state & ios::badbit; }
    int rdstate() { return _state; }
    void set(int flag) { _state |= flag; }
    operator void*() { return fail() ? (void*)0 : (void*)this; }
    int operator!() { return fail(); }









  protected:
    ios(streambuf*sb) { _strbuf=sb; _state=0; _width=0; _fill=' ';
			_flags=ios::skipws; _precision=6; }
};




typedef ios::seek_dir _seek_dir;


 
 
 
 
 















struct __streambuf {
     
    int _flags;		 
    char* _gptr;	 
    char* _egptr;	 
    char* _eback;	 
    char* _pbase;	 
    char* _pptr;	 
    char* _epptr;	 
    char* _base;	 
    char* _ebuf;	 
    struct streambuf *_chain;
};

struct streambuf : private __streambuf {
    friend class ios;
    friend class istream;
    friend class ostream;
  protected:
    static streambuf* _list_all;  
    streambuf*& xchain() { return _chain; }
    void _un_link();
    void _link_in();
    char* gptr() const { return _gptr; }
    char* pptr() const { return _pptr; }
    char* egptr() const { return _egptr; }
    char* epptr() const { return _epptr; }
    char* pbase() const { return _pbase; }
    char* eback() const { return _eback; }
    char* ebuf() const { return _ebuf; }
    char* base() const { return _base; }
    void xput_char(char c) { *_pptr++ = c; }
    int xflags() { return _flags; }
    int xflags(int f) { int fl = _flags; _flags = f; return fl; }
    void xsetflags(int f) { _flags |= f; }
    void gbump(int n) { _gptr += n; }
    void pbump(int n) { _pptr += n; }
    void setb(char* b, char* eb, int a=0);
    void setp(char* p, char* ep) { _pbase=_pptr=p; _epptr=ep; }
    void setg(char* eb, char* g, char *eg) { _eback=eb; _gptr=g; _egptr=eg; }
  public:
    static int flush_all();
    static void flush_all_linebuffered();  
    virtual int underflow();  
    virtual int overflow(int c = (-1) );  
    virtual int doallocate();
    virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
    virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out);
    int sputbackc(char c);
    int sungetc();
    streambuf();
    virtual ~streambuf();
    int unbuffered() { return _flags & 2  ? 1 : 0; }
    int linebuffered() { return _flags & 0x4000  ? 1 : 0; }
    void unbuffered(int i)
	{ if (i) _flags |= 2 ; else _flags &= ~2 ; }
    void linebuffered(int i)
	{ if (i) _flags |= 0x4000 ; else _flags &= ~0x4000 ; }
    int allocate() {
	if (base() || unbuffered()) return 0;
	else return doallocate(); }
    virtual int sync();
    virtual int pbackfail(int c);
    virtual int ungetfail();
    virtual streambuf* setbuf(char* p, int len);
    int in_avail() { return _egptr - _gptr; }
    int out_waiting() { return _pptr - _pbase; }
    virtual int sputn(const char* s, int n);
    virtual int sgetn(char* s, int n);
    long sgetline(char* buf, size_t n, char delim, int putback_delim);
    int sbumpc() {
	if (_gptr >= _egptr && underflow() == (-1) ) return (-1) ;
	else return *(unsigned char*)_gptr++; }
    int sgetc() {
	if (_gptr >= _egptr && underflow() == (-1) ) return (-1) ;
	else return *(unsigned char*)_gptr; }
    int snextc() {
	if (++_gptr >= _egptr && underflow() == (-1) ) return (-1) ;
	else return *(unsigned char*)_gptr; }
    int sputc(int c) {
	if (_pptr >= _epptr) return overflow(c);
	return *_pptr++ = c, (unsigned char)c; }
    int vscan(char const *fmt0, char*  ap);
    int vform(char const *fmt0, char*  ap);
};

struct __file_fields {
    char _fake;
    char _shortbuf[1];
    short _fileno;
    int _blksize;
    char* _save_gptr;
    char* _save_egptr;
    long  _offset;
};

class filebuf : public streambuf {
    struct __file_fields _fb;
    void init();
  public:
    filebuf();
    filebuf(int fd);
    filebuf(int fd, char* p, int len);
    ~filebuf();
    filebuf* attach(int fd);
    filebuf* open(const char *filename, const char *mode);
    filebuf* open(const char *filename, int mode, int prot = 0664);
    virtual int underflow();
    virtual int overflow(int c = (-1) );
    int is_open() { return _fb._fileno >= 0; }
    int fd() { return is_open() ? _fb._fileno : (-1) ; }
    filebuf* close();
    virtual int doallocate();
    virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
    int sputn(const char* s, int n);
    int sgetn(char* s, int n);
  protected:  
    virtual int pbackfail(int c);
    virtual int sync();
    int is_reading() { return eback() != egptr(); }
    char* cur_ptr() { return is_reading() ?  gptr() : pptr(); }
     
    char* file_ptr() { return _fb._save_gptr ? _fb._save_egptr : egptr(); }
    int do_flush();
     
    virtual int sys_read(char* buf, size_t size);
    virtual long  sys_seek(long , _seek_dir);
    virtual long sys_write(const void*, long);
    virtual int sys_stat(void*);  
    virtual int sys_close();
};









# 25 "/usr/local/lib/g++-include/iostream.h" 2 3


class istream; class ostream;
typedef istream& (*__imanip)(istream&);
typedef ostream& (*__omanip)(ostream&);

extern istream& ws(istream& ins);
extern ostream& flush(ostream& outs);
extern ostream& endl(ostream& outs);
extern ostream& ends(ostream& outs);

class ostream : public ios
{
    void do_osfx();
  public:
    ostream();
    ostream(streambuf* sb, ostream* tied=((void *)0) );
    ~ostream();

    int opfx() { if (!good()) return 0; if (_tie) _tie->flush(); return 1; }
    void osfx() { if (flags() & (ios::unitbuf|ios::stdio))
		      do_osfx(); }
    streambuf* ostreambuf() const { return _strbuf; }
    ostream& flush();
    ostream& put(char c);
    ostream& write(const char *s, int n);
    ostream& write(const unsigned char *s, int n) { return write((char*)s, n);}
    ostream& write(const void *s, int n) { return write((char*)s, n);}
    ostream& seekp(streampos);
    ostream& seekp(streamoff, _seek_dir);
    streampos tellp();
    ostream& form(const char *format ...);
    ostream& vform(const char *format, char*  args);
};

ostream& operator<<(ostream&, char c);
ostream& operator<<(ostream& os, unsigned char c) { return os << (char)c; }
 
extern ostream& operator<<(ostream&, const char *s);
inline ostream& operator<<(ostream& os, const unsigned char *s)
{ return os << (const char*)s; }
 
 
ostream& operator<<(ostream&, void *p);
ostream& operator<<(ostream&, int n);
ostream& operator<<(ostream&, long n);
ostream& operator<<(ostream&, unsigned int n);
ostream& operator<<(ostream&, unsigned long n);
ostream& operator<<(ostream& os, short n) {return os << (int)n;}
ostream& operator<<(ostream& os, unsigned short n)
{return os << (unsigned int)n;}
ostream& operator<<(ostream&, float n);
ostream& operator<<(ostream&, double n);
ostream& operator<<(ostream& os, __omanip func) { return (*func)(os); }
ostream& operator<<(ostream&, streambuf*);

class istream : public ios
{
    size_t _gcount;
  public:
    istream();
    istream(streambuf* sb, ostream*tied=((void *)0) );
    ~istream();
    streambuf* istreambuf() const { return _strbuf; }
    istream& get(char& c);
    istream& get(unsigned char& c);
    istream& read(char *ptr, int n);
    istream& read(unsigned char *ptr, int n) { return read((char*)ptr, n); }
    istream& read(void *ptr, int n) { return read((char*)ptr, n); }
    int get() { return _strbuf->sbumpc(); }
    istream& getline(char* ptr, int len, char delim = '\n');
    istream& get(char* ptr, int len, char delim = '\n');
    istream& gets(char **s, char delim = '\n');
    int ipfx(int need) {
	if (!good()) { set(ios::failbit); return 0; }
	if (_tie && (need == 0 || rdbuf()->in_avail() < need)) _tie->flush();
	if (!need && (flags() & ios::skipws) && !ws(*this)) return 0;
	return 1;
    }
    int ipfx0() {  
	if (!good()) { set(ios::failbit); return 0; }
	if (_tie) _tie->flush();
	if ((flags() & ios::skipws) && !ws(*this)) return 0;
	return 1;
    }
    int ipfx1() {  
	if (!good()) { set(ios::failbit); return 0; }
	if (_tie && rdbuf()->in_avail() == 0) _tie->flush();
	return 1;
    }
    size_t gcount() { return _gcount; }
    istream& seekg(streampos);
    istream& seekg(streamoff, _seek_dir);
    streampos tellg();
    istream& putback(char ch) {
	if (good() && _strbuf->sputbackc(ch) == (-1) ) clear(ios::badbit);
	return *this;}
    istream& unget() {
	if (good() && _strbuf->sungetc() == (-1) ) clear(ios::badbit);
	return *this;}




};

istream& operator>>(istream&, char*);
istream& operator>>(istream& is, unsigned char* p) { return is >> (char*)p; }
 
istream& operator>>(istream&, char& c);
istream& operator>>(istream&, unsigned char& c);
 
istream& operator>>(istream&, int&);
istream& operator>>(istream&, long&);
istream& operator>>(istream&, short&);
istream& operator>>(istream&, unsigned int&);
istream& operator>>(istream&, unsigned long&);
istream& operator>>(istream&, unsigned short&);
istream& operator>>(istream&, float&);
istream& operator>>(istream&, double&);
istream& operator>>(istream& is, __imanip func) { return (*func)(is); }

class iostream : public ios {
    size_t _gcount;
  public:
    iostream();
    operator istream&() { return *(istream*)this; }
    operator ostream&() { return *(ostream*)this; }
    ~iostream();
     
    istream& get(char& c) { return ((istream*)this)->get(c); }
    istream& get(unsigned char& c) { return ((istream*)this)->get(c); }
    istream& read(char *ptr, int n) { return ((istream*)this)->read(ptr, n); }
    istream& read(unsigned char *ptr, int n)
	{ return ((istream*)this)->read((char*)ptr, n); }
    istream& read(void *ptr, int n)
	{ return ((istream*)this)->read((char*)ptr, n); }
    int get() { return _strbuf->sbumpc(); }
    istream& getline(char* ptr, int len, char delim = '\n')
	{ return ((istream*)this)->getline(ptr, len, delim); }
    istream& get(char* ptr, int len, char delim = '\n')
	{ return ((istream*)this)->get(ptr, len, delim); }
    istream& gets(char **s, char delim = '\n')
	{ return ((istream*)this)->gets(s, delim); }
    int ipfx(int need) { return ((istream*)this)->ipfx(need); }
    int ipfx0()  { return ((istream*)this)->ipfx0(); }
    int ipfx1()  { return ((istream*)this)->ipfx1(); }
    size_t gcount() { return _gcount; }
    istream& putback(char ch) { return ((istream*)this)->putback(ch); }
    istream& unget() { return ((istream*)this)->unget(); }
    istream& seekg(streampos pos) { return ((istream*)this)->seekg(pos); }
    istream& seekg(streamoff off, _seek_dir dir)
	{ return ((istream*)this)->seekg(off, dir); }
    streampos tellg() { return ((istream*)this)->tellg(); }




     
    int opfx() { return ((ostream*)this)->opfx(); }
    void osfx() { ((ostream*)this)->osfx(); }
    ostream& flush() { return ((ostream*)this)->flush(); }
    ostream& put(char c) { return ((ostream*)this)->put(c); }
    ostream& write(const char *s, int n)
	{ return ((ostream*)this)->write(s, n); }
    ostream& write(const unsigned char *s, int n)
	{ return ((ostream*)this)->write((char*)s, n); }
    ostream& write(const void *s, int n)
	{ return ((ostream*)this)->write((char*)s, n); }
    ostream& form(const char *format ...);
    ostream& vform(const char *format, char*  args)
	{ return ((ostream*)this)->vform(format, args); }
    ostream& seekp(streampos pos) { return ((ostream*)this)->seekp(pos); }
    ostream& seekp(streamoff off, _seek_dir dir)
	{ return ((ostream*)this)->seekp(off, dir); }
    streampos tellp() { return ((ostream*)this)->tellp(); }
};

extern istream cin;
extern ostream cout, cerr, clog;  

inline ostream& ostream::put(char c) { _strbuf->sputc(c); return *this; }

struct Iostream_init { } ;   


# 1 "Date.h" 2


class Date {
	int month, day, year;
public:
	Date(int d, int m, int y) {day = d; month = m; year = y;}
	Date(const Date&);
	Date() {day = 20; month = 8; year = 1992;}
	Date& operator=(const Date&);
	void print() { cout << day << '/' << month << '/' << year << '\n' ;}
	int CMP(Date& , Date&);
};

inline int Date::CMP(Date& a, Date& b)
{
	long int n1 = 10000 * a.year + 100 * a.month + a.day;
	long int n2 = 10000 * b.year + 100 * b.month + b.day;
	return (n1 <= n2) ? ((n1 == n2) ? 0 : -1) : 1;
}
	
# 2 "tSList.cc" 2

int main()
{
	Date d(20,8,92);
	SList<Date> ilst;
	 






























}


	
----------
X-Sun-Data-Type: default
X-Sun-Data-Name: tSList.cc
X-Sun-Content-Lines: 41

#include "SList.h"
#include "Date.h"
int main()
{
	Date d(20,8,92);
	SList<Date> ilst;
	/*ilst.insert(Date(12,8,1992));
	ilst.insert(Date(13,8,1992));
	ilst.insert(Date(14,8,1992));
	ilst.append(Date(15,8,1992));
	ilst.append(Date(16,8,1992));
	ilst.insert(Date(17,8,1992));
	Date d = ilst.get();
	d.print();
 	d = ilst.get();
	d.print();
	d = ilst.get();
	d.print();
	d = ilst.get();
	d.print();
	d = ilst.get();
	d.print();
	d = ilst.get();
	d.print();
	ilst.append(Date(18,8,1992));
	ilst.insert(Date(19,8,1992));
	d = ilst.get();
	d.print();
	d = ilst.get();
	d.print();
	ilst.insert(Date(20,8,1992));
	ilst.insert(Date(21,8,1992));
	d = ilst.get();
	d.print();
	d = ilst.get();
	d.print();
	exit(0);*/
}


	
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