🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #872

Another fatal signal in g++-2.2.2

#872
From: Vance Maverick
Date: Tue, 01 Sep 1992 16:53
1727 lines
35408 bytes
Hi,
	Here's another file which causes a fatal error.  It is
somewhat longer than the last one I sent you.  Sample compilation:

mahogany% g++-2.2.2 -g  -c Stream.ii -o test.out
/usr/sww/bin/gcc-2.2.2: Internal compiler error: program cc1plus got fatal signal 6
mahogany%

	Hope these examples are informative,

		Vance

--------------------- Begin Stream.ii --------------------
# 1 "Stream.cc"
 
 
 
 
 
 
 

# 1 "Stream.h" 1
 
 
 
 
 
 
 


#pragma interface


# 1 "../common/common.h" 1
 
 
 
 
 
 
 




# 1 "/usr/sww/lib/g++-include-2.2.2/ostream.h" 1 3
# 1 "/usr/sww/lib/g++-include-2.2.2/stream.h" 1 3



 


# 1 "/usr/sww/lib/g++-include-2.2.2/iostream.h" 1 3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 



#pragma interface




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





#pragma interface


# 1 "/usr/sww/lib/g++-include-2.2.2/_G_config.h" 1 3
  





















 












 





 
 

# 23 "/usr/sww/lib/g++-include-2.2.2/streambuf.h" 2 3















class ostream; class streambuf; class backupbuf;





extern "C" int __underflow(streambuf*);
extern "C" int __overflow(streambuf*, int);

typedef long  streamoff;
typedef long  streampos;  

typedef unsigned long __fmtflags;

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















enum state_value {
    _good = 0 ,
    _eof = 1 ,
    _fail = 2 ,
    _bad = 4  };
enum open_mode {
    input = 1 ,
    output = 2 ,
    atend = 4 ,
    append = 8  };


class ios : public _ios_fields {
  public:
    typedef __fmtflags fmtflags;
    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() const { return _tie; }
    ostream* tie(ostream* val) { ostream* save=_tie; _tie=val; return save; }

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

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

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


    void unset(state_value flag) { _state &= ~flag; }
    void close();
    int is_open();
    int readable();
    int writable();


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




typedef ios::seek_dir _seek_dir;


 
 
 
 
 



















 
 
class streammarker {
    friend class streambuf;



    friend int __underflow(streambuf*);

    struct streammarker *_next;   
    streambuf *_sbuf;  
    streampos _spos;  
    void set_streampos(streampos sp) { _spos = sp; }
    void set_offset(int offset) { _pos = offset; _spos = (streampos)(-2); }
     
     
    int _pos;
  public:
    streammarker(streambuf *sb);
    ~streammarker();
    int saving() { return  _spos == -2; }
    int delta(streammarker&);
    int delta();
};

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

     
    friend class streammarker;
    char *_other_gbase;  
    char *_aux_limit;   
    char *_other_egptr;  
    streammarker *_markers;


     
    unsigned short _cur_column;
    char _unused;
    char _shortbuf[1];
};

extern unsigned __adjust_column(unsigned start, const char *line, int count);

struct streambuf : private __streambuf {
    friend class ios;
    friend class istream;
    friend class ostream;
    friend class streammarker;



    friend int __underflow(streambuf*);

  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 xsetflags(int f, int mask) { _flags = (_flags & ~mask) | (f & mask); }
    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; }
    char *shortbuf() { return _shortbuf; }

    int in_backup() { return _flags & 0x100 ; }
     
    char *Gbase() { return in_backup() ? _other_gbase : _eback; }
     
    char *eGptr() { return in_backup() ? _other_egptr : _egptr; }
     
    char *Bbase() { return in_backup() ? _eback : _other_gbase; }
    char *Bptr() { return _aux_limit; }
     
    char *eBptr() { return in_backup() ? _egptr : _other_egptr; }
    char *Nbase() { return _other_gbase; }
    char *eNptr() { return _other_egptr; }
    int have_backup() { return _other_gbase != ((void*)0) ; }
    int have_markers() { return _markers != ((void*)0) ; }
    int _least_marker();
    void switch_to_main_get_area();
    void switch_to_backup_area();
    void free_backup_area();
    void unsave_markers();  
    int put_mode() { return _flags & 0x800 ; }
    int switch_to_get_mode();
    
    streambuf(int flags=0);
  public:
    static int flush_all();
    static void flush_all_linebuffered();  
    virtual int underflow() = 0;  
    virtual int overflow(int c = (-1) ) = 0;  
    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 seekmark(streammarker& mark, int delta = 0);
    int sputbackc(char c);
    int sungetc();
    virtual ~streambuf();
    int unbuffered() { return _flags & 2  ? 1 : 0; }
    int linebuffered() { return _flags & 0x200  ? 1 : 0; }
    void unbuffered(int i)
	{ if (i) _flags |= 2 ; else _flags &= ~2 ; }
    void linebuffered(int i)
	{ if (i) _flags |= 0x200 ; else _flags &= ~0x200 ; }
    int allocate() {  
	if (base() || unbuffered()) return 0;
	else return doallocate(); }
     
    void allocbuf() { if (base() == ((void*)0) ) doallocbuf(); }
    void doallocbuf();
    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);
    int ignore(int);
    virtual int get_column();
    virtual int set_column(int);
    long sgetline(char* buf, int  n, char delim, int putback_delim);
    int sbumpc() {
	if (_gptr >= _egptr && __underflow(this) == (-1) ) return (-1) ;
	else return *(unsigned char*)_gptr++; }
    int sgetc() {
	if (_gptr >= _egptr && __underflow(this) == (-1) ) return (-1) ;
	else return *(unsigned char*)_gptr; }
    int snextc() {
	if (++_gptr >= _egptr && __underflow(this) == (-1) ) return (-1) ;
	else return *(unsigned char*)_gptr; }
    int sputc(int c) {
	if (_pptr >= _epptr) return __overflow(this, (unsigned char)c);
	return *_pptr++ = c, (unsigned char)c; }
    void stossc() { if (_gptr < _egptr) _gptr++; }
    int vscan(char const *fmt0, char *  ap);
    int vform(char const *fmt0, char *  ap);




};

 
 

 
 
 
 

class backupbuf : public streambuf {
    friend class streammarker;
  protected:
    backupbuf(int flags=0) : streambuf(flags|0x4000 ) { }
  public:
    virtual int pbackfail(int c);
    virtual int underflow();
    virtual int overflow(int c = (-1) );
};

struct __file_fields {
    short _fileno;
    int _blksize;
    long   _offset;
 
};

class filebuf : public backupbuf {
  protected:
    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);
    virtual int sync();
  protected:  
 
    int is_reading() { return eback() != egptr(); }
    char* cur_ptr() { return is_reading() ?  gptr() : pptr(); }
     
    char* file_ptr() { return eGptr(); }
    int do_flush();
     
    virtual int  sys_read(char* buf, int  size);
    virtual long   sys_seek(long  , _seek_dir);
    virtual int  sys_write(const void*, long);
    virtual int sys_stat(void*);  
    virtual int sys_close();
};


inline int ios::readable() { return !(rdbuf()->_flags & 4 ); }
inline int ios::writable() { return !(rdbuf()->_flags & 8 ); }
inline int ios::is_open() { return (rdbuf()->_flags & 4 +8 )
				!= 4 +8 ; }



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


class istream; class ostream;
typedef ios& (*__manip)(ios&);
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) { _strbuf->sputc(c); return *this; }

    ostream& write(const char *s, int n);
    ostream& write(const unsigned char *s, int n) { return write((char*)s, n);}

    ostream& write(const signed 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);
};

extern ostream& operator<<(ostream&, char c);
inline ostream& operator<<(ostream& os, unsigned char c)
{ return os << (char)c; }

extern ostream& operator<<(ostream &os, signed 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; }

inline ostream& operator<<(ostream& os, const signed char *s)
{ return os << (const char*)s; }

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

class istream : public ios
{
    int  _gcount;

    int _skip_ws();
  public:
    istream();
    istream(streambuf* sb, ostream*tied=((void*)0) );
    ~istream();
    streambuf* istreambuf() const { return _strbuf; }
    istream& get(char& c);
    istream& get(unsigned char& c) { return get((char&)c); }

    istream& get(signed char& c)  { return get((char&)c); }

    istream& read(char *ptr, int n);
    istream& read(unsigned char *ptr, int n) { return read((char*)ptr, n); }

    istream& read(signed char *ptr, int n) { return read((char*)ptr, n); }

    istream& read(void *ptr, int n) { return read((char*)ptr, n); }
     
    istream& getline(char* ptr, int len, char delim = '\n');
    istream& get(char* ptr, int len, char delim = '\n');
    istream& get(streambuf& sb, 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)) return _skip_ws();
	return 1;
    }
    int ipfx0() {  
	if (!good()) { set(ios::failbit); return 0; }
	if (_tie) _tie->flush();
	if (flags() & ios::skipws) return _skip_ws();
	return 1;
    }
    int ipfx1() {  
	if (!good()) { set(ios::failbit); return 0; }
	if (_tie && rdbuf()->in_avail() == 0) _tie->flush();
	return 1;
    }
    int get() { if (!ipfx1()) return (-1) ;
		int ch = _strbuf->sbumpc();
		if (ch == (-1) ) set(ios::eofbit);
		return ch; }
    int peek() { if (!ipfx1()) return (-1) ;
		int ch = _strbuf->sgetc();
		if (ch == (-1) ) set(ios::eofbit);
		return ch; }
    int  gcount() { return _gcount; }
    istream& ignore(int n=1, int delim = (-1) );
    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& scan(const char *format ...);
    istream& vscan(const char *format, char *  args);

    istream& unget(char ch) { return putback(ch); }
    int skip(int i);

};

extern istream& operator>>(istream&, char*);
inline istream& operator>>(istream& is, unsigned char* p)
{ return is >> (char*)p; }

inline istream& operator>>(istream& is, signed char*p) {return is >> (char*)p;}

extern istream& operator>>(istream&, char& c);
extern istream& operator>>(istream& s, unsigned char& c) {return s>>(char&)c;}

extern istream& operator>>(istream& s, signed char& c) {return s >> (char&)c;}

extern istream& operator>>(istream&, int&);
extern istream& operator>>(istream&, long&);
extern istream& operator>>(istream&, short&);
extern istream& operator>>(istream&, unsigned int&);
extern istream& operator>>(istream&, unsigned long&);
extern istream& operator>>(istream&, unsigned short&);
extern istream& operator>>(istream&, float&);
extern istream& operator>>(istream&, double&);
inline istream& operator>>(istream& is, __manip func) {(*func)(is); return is;}
inline istream& operator>>(istream& is, __imanip func) { return (*func)(is); }
extern istream& operator>>(istream&, streambuf*);

class iostream : public ios {
    int  _gcount;
  public:
    iostream();
    iostream(streambuf* sb, ostream*tied=((void*)0) );
    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((char&)c); }

    istream& get(signed char& c) { return ((istream*)this)->get((char&)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(signed char *ptr, int n)
	{ return ((istream*)this)->read((char*)ptr, n); }

    istream& read(void *ptr, int n)
	{ return ((istream*)this)->read((char*)ptr, n); }
    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); }
    istream& ignore(int n=1, int delim = (-1) )
	{ return ((istream*)this)->ignore(n, delim); }
    int ipfx(int need) { return ((istream*)this)->ipfx(need); }
    int ipfx0()  { return ((istream*)this)->ipfx0(); }
    int ipfx1()  { return ((istream*)this)->ipfx1(); }
    int get() { return _strbuf->sbumpc(); }
    int peek() { return ipfx1() ? _strbuf->sgetc() : (-1) ; }
    int  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(); }
    istream& scan(const char *format ...);
    istream& vscan(const char *format, char *  args)
	{ return ((istream*)this)->vscan(format, args); }

    istream& unget(char ch) { return putback(ch); }


     
    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 signed 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;  

struct Iostream_init { } ;   

inline ios& dec(ios& i)
{ i.setf(ios::dec, ios::dec|ios::hex|ios::oct); return i; }
inline ios& hex(ios& i)
{ i.setf(ios::hex, ios::dec|ios::hex|ios::oct); return i; }
inline ios& oct(ios& i)
{ i.setf(ios::oct, ios::dec|ios::hex|ios::oct); return i; }


# 7 "/usr/sww/lib/g++-include-2.2.2/stream.h" 2 3


extern char* form(const char*, ...);

extern char* dec(long, int=0);
extern char* dec(int, int=0);
extern char* dec(unsigned long, int=0);
extern char* dec(unsigned int, int=0);

extern char* hex(long, int=0);
extern char* hex(int, int=0);
extern char* hex(unsigned long, int=0);
extern char* hex(unsigned int, int=0);

extern char* oct(long, int=0);
extern char* oct(int, int=0);
extern char* oct(unsigned long, int=0);
extern char* oct(unsigned int, int=0);

inline istream& WS(istream& str) { return ws(str); }


# 1 "/usr/sww/lib/g++-include-2.2.2/ostream.h" 2 3

# 12 "../common/common.h" 2

# 1 "/usr/sww/lib/g++-include-2.2.2/minmax.h" 1 3
 
























inline char min(char a, char b) { return (a < b)?a:b;}

inline signed char min(signed char a, signed char b) { return (a < b)?a:b;}

inline unsigned char min(unsigned char a, unsigned char b) {return (a<b)?a:b;}

inline short min(short a, short b) {return (a < b) ?a:b;}
inline unsigned short min(unsigned short a, unsigned short b) {return (a < b)?a:b;}

inline int min(int a, int b) {return (a < b)?a:b;}
inline unsigned int min(unsigned int a, unsigned int b) {return (a < b)?a:b;}

inline long min(long a, long b) {return (a < b)?a:b;}
inline unsigned long min(unsigned long a, unsigned long b) {return (a<b)?a:b;}

inline float min(float a, float b) {return (a < b)?a:b;}

inline double min(double a, double b) {return (a < b)?a:b;}

inline char max(char a, char b) { return (a > b)?a:b;}

inline signed char max(signed char a, signed char b) {return (a > b)?a:b;}

inline unsigned char max(unsigned char a, unsigned char b) {return (a>b)?a:b;}

inline short max(short a, short b) {return (a > b) ?a:b;}
inline unsigned short max(unsigned short a, unsigned short b) {return (a > b)?a:b;}

inline int max(int a, int b) {return (a > b)?a:b;}
inline unsigned int max(unsigned int a, unsigned int b) {return (a > b)?a:b;}

inline long max(long a, long b) {return (a > b)?a:b;}
inline unsigned long max(unsigned long a, unsigned long b) {return (a>b)?a:b;}

inline float max(float a, float b) {return (a > b)?a:b;}

inline double max(double a, double b) {return (a > b)?a:b;}



# 13 "../common/common.h" 2


enum bool { FALSE, TRUE };

 


extern "C" {
extern void exit(int);

}






 

void warning(char *);			 
void error(char *);			 
void panic(char *);			 


# 13 "Stream.h" 2

# 1 "TPVec.h" 1
 
 
 
 
 
 
 


#pragma interface


# 1 "../time/Timepoint.h" 1
 
 
 
 
 
 
 


#pragma interface


# 1 "../common/common.h" 1
 
 
 
 
 
 
 

# 36 "../common/common.h"

# 13 "../time/Timepoint.h" 2

# 1 "../time/Divisor.h" 1
 
 
 
 
 
 
 


#pragma interface


 

class Divisor {
  protected:
    int _ndiv;
    int _depth;				 

  public:

    virtual float time(int index) = 0;
    virtual float start() = 0;
    virtual float end() = 0;
    
    int ndiv() { return _ndiv; }
    int depth() { return _depth; }	 
};


# 14 "../time/Timepoint.h" 2


class Timepoint {
    Divisor *d;				 
    int i;				 

  public:
    Timepoint(Divisor *divisor, int index) {
	d = divisor;
	i = index;
    }

    float time() { return d->time(i); }

    Divisor *divisor() { return d; }
    int index() { return i; }
};

 
 

extern bool operator>(Timepoint *, Timepoint *);

inline bool operator<=(Timepoint *a, Timepoint *b) {
    return (!(a > b));
}

extern bool operator<(Timepoint *, Timepoint *);

inline bool operator>=(Timepoint *a, Timepoint *b) {
    return (!(a < b));
}


# 13 "TPVec.h" 2

# 1 "NoteList.h" 1
 
 
 
 
 
 
 


#pragma interface


# 1 "../common/common.h" 1
 
 
 
 
 
 
 

# 36 "../common/common.h"

# 13 "NoteList.h" 2


class Note;

class NoteList {
    class NoteLink {
      friend class NoteList;
	NoteLink *next;
	Note *note;
    };
    NoteLink *list;

    static NoteLink *freelist;

  public:
    ~NoteList() {
	if (list != ((void*)0) ) clear();
    }
    
    void init() { list = ((void*)0) ; }

     

    void add(Note *);
    void del(Note *);

     

    void clear();

     

    long first() { return long(list); }

    long next(int iter) {
	NoteLink *link = (NoteLink *)(iter);
	if (link == ((void*)0) )
	    return 0;
	else return long(link->next);
    }

    Note *note(int iter) {
	return ((NoteLink *)iter)->note;
    }
};


# 14 "TPVec.h" 2


 

struct TPRec {
    Timepoint *tp;
    NoteList starts;			 
    NoteList ends;			 
};

 

class TPVec {
    int sz, ln;
    TPRec *array;

     

    TPVec(int len) { init(len); }	 

    void init(int len);			 

    void expand(int delta = 1);		 

    int size() { return sz; }

  public:
    TPVec() { init(0); }

    ~TPVec() {
	delete array;
    }

     

    int len() { return ln; }

    TPRec &operator[](int index) {
	return array[index];
    }

    Timepoint *tp(int index) {
	return (*this)[index].tp;
    }
    NoteList &starts(int index) {
	return (*this)[index].starts;
    }
    NoteList &ends(int index) {
	return (*this)[index].ends;
    }

     

    int index_by_time(float time);

     

    TPVec *copy_section(int start_index, int count);

    void delete_section(int start_index, int count);

    TPVec *cut_section(int start_index, int count) {
	TPVec *copy = copy_section(start_index, count);
	delete_section(start_index, count);
	return copy;
    }

     

    void insert_timepoint(Timepoint *tp);
    void insert_timepoints(Timepoint **tparray, int count);

    void make_room(int base, int count);
};


# 14 "Stream.h" 2


class Timepoint;
class Tuning;
class Divisor;
class RelDivisor;
class AbsDivisor;
class DivisorList;
class Pitch;

class Stream {
    TPVec tpvec;			 
    int _ndivisors;			 
    DivisorList *div;			 
    Stream *_parent;			 
    Tuning *_tuning;			 

  public:
    Stream();				 

    int npoints() {
	return tpvec.len();
    }

    Timepoint *timepoint(int index) {
	if (index >= 0 && index < npoints())
	    return tpvec.tp(index);
	else return ((void*)0) ;
    }

    int ndivisors() { return _ndivisors; }
    Divisor *divisor(int index);	 

     

    int timepoint_index(Timepoint *);

    void timepoint_index_pair(Timepoint *a,  
			      Timepoint *b,
			      int &a_index, int &b_index);

     

    RelDivisor *add_rel_divisor(int from, int to, int ndiv);

    RelDivisor *add_rel_divisor(Timepoint *from, Timepoint *to, int ndiv) {
	int f_index, t_index;

	timepoint_index_pair(from, to, f_index, t_index);

	return add_rel_divisor(f_index, t_index, ndiv);
    }

    AbsDivisor *add_abs_divisor(float from, float to, int ndiv);

     

    int index_timepoint_after(float time) {
	return tpvec.index_by_time(time);
    }

    Timepoint *timepoint_after(float time) {
	return timepoint(index_timepoint_after(time));
    }

     

    Stream *parent() { return _parent; }

     

    Tuning *tuning() {
	Stream *scan = this;

	while (scan->_tuning == ((void*)0) )
	    scan = scan->parent();

	return scan->_tuning;
    }

     

    Note *insert_note(int start, int end, Pitch *p);

    Note *insert_note(Timepoint *start, Timepoint *end, Pitch *p) {
	int s_index, e_index;
	
	timepoint_index_pair(start, end, s_index, e_index);

	return insert_note(s_index, e_index, p);
    }

     

    void print();
};


# 9 "Stream.cc" 2

# 1 "../time/AbsDivisor.h" 1
 
 
 
 
 
 
 


#pragma interface


# 1 "../time/Divisor.h" 1
 
 
 
 
 
 
 

# 30 "../time/Divisor.h"

# 13 "../time/AbsDivisor.h" 2


class AbsDivisor : public Divisor {
    float _start, _end, diff;

  public:
    AbsDivisor(float start, float end, int ndiv) {
	_start = start;
	_end = end;
	diff = end - start;
	_depth = 0;
	_ndiv = ndiv;
    }

    virtual float start() { return _start; }
    virtual float end() { return _end; }

    virtual float time(int index) {
	return _start + (diff * (float(index)/float(_ndiv)));
    }
};


# 10 "Stream.cc" 2

# 1 "../time/RelDivisor.h" 1
 
 
 
 
 
 
 


#pragma interface


# 1 "../time/Divisor.h" 1
 
 
 
 
 
 
 

# 30 "../time/Divisor.h"

# 13 "../time/RelDivisor.h" 2

# 1 "../time/Timepoint.h" 1
 
 
 
 
 
 
 

# 47 "../time/Timepoint.h"

# 14 "../time/RelDivisor.h" 2


class RelDivisor : public Divisor {
    Timepoint *s, *e;

  public:
     
     

    RelDivisor(Timepoint *start, Timepoint *end, int ndiv,
	       int depth = -1);

     

    virtual float start() { return s->time(); }
    virtual float end() { return e->time(); }

     

    virtual float time(int index);
};


# 11 "Stream.cc" 2

# 1 "../pitch/Tuning.h" 1
 
 
 
 
 
 
 


#pragma interface


class Pitch;

class Tuning {
    Pitch **p;
    int np;

  public:
    Tuning();
    
    int npitches() {
	return np;
    }
    Pitch *pitch(int index) {
	return p[index];
    }

    float frequency(Pitch *);
};


# 12 "Stream.cc" 2

# 1 "Note.h" 1
 
 
 
 
 
 
 


#pragma interface


# 1 "../common/Identifier.h" 1
 











# 1 "../common/common.h" 1
 
 
 
 
 
 
 

# 36 "../common/common.h"

# 13 "../common/Identifier.h" 2


class Identifier {
    char *str;

  public:
    Identifier(char *);

    const char *chars() {
	return str;
    }
    
    bool operator==(Identifier other) {
	return (str == other.str);
    }

    static const Identifier null;
};


# 13 "Note.h" 2


class Pitch;
class Timepoint;

class Note {
    Pitch *p;				 
    Timepoint *s;			 
    Timepoint *e;			 
    Identifier i;			 
    float a;

  public:
     

    Note(Pitch *pitch, Timepoint *start, Timepoint *end,
	 Identifier inst = Identifier::null, float amp = 1.0)
    : i(inst) {

	p = pitch;
	s = start;
	e = end;
	a = amp;
    }

     

    Pitch *pitch() {
	return p;
    }
    Timepoint *start() {
	return s;
    }
    Timepoint *end() {
	return e;
    }
    Identifier inst() {
	return i;
    }
    float amp() {
	return a;
    }
};


# 13 "Stream.cc" 2


static const char RCSid[] = "$Header: /home/yew/yew5/users/maverick/music/arugula/struct/RCS/Stream.cc,v 1.4 1992/09/01 00:51:20 maverick Exp maverick $";

 

class DivisorList {
  friend class Stream;

    DivisorList *next;
    Divisor *div;
    int nhidden;			 
    TPVec *hidden;			 
    
    DivisorList(DivisorList *n, Divisor *d, int nh, TPVec *h) {
	next = n;
	div = d;
	nhidden = nh;
	hidden = h;
    }
};

 

Stream::Stream() {

    _ndivisors = 0;
    div = ((void*)0) ;
    _parent = ((void*)0) ;
    _tuning = new Tuning;
}

 

Divisor *Stream::divisor(int index) {
    
    if (index < 0 || index >= ndivisors()) {
	return ((void*)0) ;
    } else {
	int i = 0;
	DivisorList *scan = div;

	while (i++ < index)
	    scan = scan->next;

	return scan->div;
    }
}

 

int Stream::timepoint_index(Timepoint *tp) {

    int index = 0;
    while ((index < npoints()) && (timepoint(index) != tp))
	index++;

    if (index == npoints())
	panic("Stream::timepoint_index -- can't match timepoint");

    return index;
}

 

void Stream::timepoint_index_pair(Timepoint *from,
				  Timepoint *to,
				  int &fromindex, int &toindex) {

     

    fromindex = 0;

    while ((fromindex < npoints()) && (timepoint(fromindex) != from))
	fromindex++;

    if (fromindex == npoints())
	panic("Stream::timepoint_index_pair -- can't match from");

    toindex = fromindex + 1;

    while ((toindex < npoints()) && (timepoint(toindex) != to))
	toindex++;
    
    if (toindex == npoints())
	panic("timepoint_index_pair -- can't match to");
}

 

RelDivisor *Stream::add_rel_divisor(int fromindex, int toindex, int ndiv) {

    int i, depth;

     

    depth = 0;
    for (i=fromindex; i<=toindex; i++) {
	int tmp = timepoint(i)->divisor()->depth();
	if (tmp > depth) depth = tmp;
    }

    RelDivisor *rd = new RelDivisor(timepoint(fromindex),
				    timepoint(toindex),
				    ndiv,
				    depth+1);

     

    int nhidden = (toindex - fromindex) - 1;

    TPVec *hidden;
    if (nhidden == 0) hidden = ((void*)0) ;
    else hidden = tpvec.cut_section(fromindex+1, nhidden);

     

    DivisorList *dl = new DivisorList(((void*)0) , rd, nhidden, hidden);

    DivisorList **scan = &div;
    while (*scan != ((void*)0) )
	scan = &(*scan)->next;
    *scan = dl;

     

    tpvec.make_room(fromindex + 1, ndiv - 1);
    for (i = 1; i < ndiv; i++)
	tpvec[fromindex+i].tp = new Timepoint(rd, i);

    return rd;
}

 

AbsDivisor *Stream::add_abs_divisor(float from, float to, int ndiv) {

     

    AbsDivisor *ad = new AbsDivisor(from, to, ndiv);

     

    DivisorList *dl = new DivisorList(((void*)0) , ad, 0, ((void*)0) );

    DivisorList **scan = &div;
    while (*scan != ((void*)0) )
	scan = &(*scan)->next;
    *scan = dl;

     

    int base = index_timepoint_after(from);
    tpvec.make_room(base, ndiv+1);
    for (int i = 0; i <= ndiv; i++)
	tpvec[base+i].tp = new Timepoint(ad, i);

    return ad;
}

 

Note *Stream::insert_note(int s_index, int e_index, Pitch *p) {

    TPRec *s = &tpvec[s_index],
	*e = &tpvec[e_index];

    Note *n = new Note(p, s->tp, e->tp);

    s->starts.add(n);
    e->ends.add(n);

    return n;
}

 

void Stream::print() {

    cout << "Stream: " << npoints() << " timepoints\n";
    
    for (int i=0; i<npoints(); i++) {
	Timepoint *t = timepoint(i);
	cout << "\t["
	    << t->divisor()->depth() << ", " << t->index() << "] = "
	    << t->time()
	    << " \n";
    }
}
Technical Details
Message-ID: <9209011653.AA08478@mahogany.CS.Berkeley.EDU>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!mahogany.cs.berkeley.edu!maverick

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!mahogany.cs.berkeley.edu!maverick
From: maverick@mahogany.cs.berkeley.edu (Vance Maverick)
Subject: Another fatal signal in g++-2.2.2
Message-ID: <9209011653.AA08478@mahogany.CS.Berkeley.EDU>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Tue, 1 Sep 1992 16:53:54 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 1728