Path: utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!LANL.GOV!gam%ranger From: gam%ranger@LANL.GOV (Graham Mark) Newsgroups: gnu.g++.bug Subject: G++ bug Message-ID: <8906051907.AA12523@targhee.lanl.gov> Date: 5 Jun 89 19:07:09 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 879 I've run into something that appears to be a compiler bug. Here are some facts: "g++ -v" returns: GNU C++ compiler driver, version 1.18.2 /usr/local/lib/gcc-ld++ -C /usr/local/lib/gcc-crt0+.o -lg++ /usr/local/lib/gcc-gnulib+ -lc The source goes through the preprocessor OK. I'll append the output resulting from "g++ -E". After trying to compile my source with "g++ -g -c dlink.cc" or with "g++ -c dlink.cc" I get back g++: Program c++ got fatal signal 6. I'm using a Sun 3/50 running Sun OS 4.0.1. The person who installed the compiler said to tell you that the tm.h and md files are for Sun 3. Please let me know if you need more information. Graham Mark ------------------------------------------------------------------- # 1 "dlink.cc" # 1 "/usr/local/lib/gcc-include/stream.h" # 1 "/usr/local/lib/gcc-include/File.h" # 1 "/usr/local/lib/gcc-include/stdio.h" extern struct _iobuf { int _cnt; char* _ptr; char* _base; int _bufsiz; short _flag; char _file; } _iob[]; extern int _doprnt(const char*, void*, struct _iobuf *); extern int _doscan( struct _iobuf *, const char*, void*); extern int _filbuf( struct _iobuf *); extern int _flsbuf(unsigned, struct _iobuf *); extern int fclose( struct _iobuf *); extern struct _iobuf * fdopen(int, const char*); extern int fflush( struct _iobuf *); extern int fgetc( struct _iobuf *); extern char* fgets(char*, int, struct _iobuf *); extern struct _iobuf * fopen(const char*, const char*); extern int fprintf( struct _iobuf *, const char* ...); extern int fputc(int, struct _iobuf *); extern void fputs(const char*, struct _iobuf *); extern int fread(void*, int, int, struct _iobuf *); extern struct _iobuf * freopen(const char*, const char*, struct _iobuf *); extern int fscanf( struct _iobuf *, const char* ...); extern int fseek( struct _iobuf *, long, int); extern long ftell( struct _iobuf *); extern int fwrite(const void*, int, int, struct _iobuf *); extern char* gets(char*); extern int getw( struct _iobuf *); extern int pclose( struct _iobuf *); extern struct _iobuf * popen(const char*, const char*); extern int printf(const char* ...); extern void puts(const char*); extern int putw(int, struct _iobuf *); extern int scanf(const char* ...); extern void setbuf( struct _iobuf *, char*); extern void setbuffer( struct _iobuf *, char*, int); extern void setlinebuf( struct _iobuf *); extern void setvbuf( struct _iobuf *, char*, int, int); extern int sprintf(char*, const char* ...); extern int sscanf(char*, const char* ...); extern struct _iobuf * tmpfile(); extern int ungetc(int, struct _iobuf *); extern int vfprintf( struct _iobuf *, const char*, void* ap); extern int vprintf(const char*, void* ap); extern int vsprintf(char*, const char*, void* ap); # 27 "/usr/local/lib/gcc-include/File.h" enum io_mode { io_readonly = 0, io_writeonly = 1, io_readwrite = 2, io_appendonly = 3, io_append = 4, }; enum access_mode { a_createonly = 0, a_create = 1, a_useonly = 2, a_use = 3, }; enum state_value { _good = 0, _eof = 00020 , _fail = 00040 , _bad = 0400000 }; class String; class File { struct _iobuf * fp; char* nm; int stat; char opened; char perrors; public: File& initialize() {fp=0; nm=0; opened=0; stat=0; perrors=1; return(*this);} File& open(const char* filename, io_mode m, access_mode a); File& open(const char* filename, const char* m); File& open(int filedesc, io_mode m); File& open( struct _iobuf * fileptr); File& close(); File& remove(); File() { initialize(); } File(const char* filename, io_mode m, access_mode a) { initialize(); open(filename, m, a); } File(const char* filename, const char* m) { initialize(); open(filename, m); } File(int filedesc, io_mode m) { initialize(); open(filedesc, m); } File( struct _iobuf * fileptr) { initialize(); open(fileptr); } ~File(); int filedesc() { return(fp->_file); } int is_open() { return(opened); } char* name() { return(nm); } void setname(const char* newname); int rdstate() { return((fp==0) ? _bad : (opened) ? fp->_flag&(_eof|_fail) : _bad|(fp->_flag&(_eof|_fail))); } void* operator void*() { return((fp==0||(fp->_flag&_fail))? 0 : this); } int eof() { return(rdstate() & _eof); } int fail() { return(rdstate() & _fail); } int bad() { return(rdstate() & _bad); } int good() { return(rdstate() == _good); } int iocount() { return(stat); } int readable() { return(fp->_flag &( 00001 | 00400 )); } int writable() { return(fp->_flag &( 00002 | 00400 )); } void verbose() { perrors = 1; } void quiet() { perrors = 0; } File& clear() { if (fp!=0) fp->_flag &= ~(_fail); return(*this); } File& error(); File& failif(int cond) { return( (cond) ? error(): *this); } File& get(char& c) { if (--fp->_cnt >= 0) { c = *fp->_ptr++; return(*this); } c = ::_filbuf(fp); return(failif(fp->_flag & _eof)); } File& put(char c) { if (--fp->_cnt >= 0) *fp->_ptr++ = c; else ::_flsbuf((unsigned)c, fp); return(*this); } File& unget(char c) { return(failif(::ungetc(c, fp)== (-1) ));} File& putback(char c) { return(File::unget(c)); } File& put(const char* s) { ::fputs(s, fp); return(*this); } File& get (char* s, int n, char terminator = '\n'); File& getline(char* s, int n, char terminator = '\n'); File& put(String& x); File& get (String& x, int n, char terminator = '\n'); File& getline(String& x, int n, char terminator = '\n'); File& read(void* x, int sz, int n) { return(failif((stat = ::fread(x, sz, n, fp)) != n)); } File& write(void* x, int sz, int n) { return(failif((stat = ::fwrite(x, sz, n, fp)) != n)); } File& form(const char* fmt, ...); File& scan(const char* fmt, ...); File& flush() { return(failif(::fflush(fp)== (-1) )); } File& seek(long pos, int seek_mode = 0) { return(failif (::fseek(fp, pos, seek_mode) < 0)); } int tell() { return(stat = ::ftell(fp)); } File& setbuf(int buffer_kind); File& raw() { return(File::setbuf( 00004 )); } File& setbuf(int size, char* buf); }; char* hex(long x, int width = 0); char* oct(long x, int width = 0); char* dec(long x, int width = 0); char* form(const char* fmt ...); # 27 "/usr/local/lib/gcc-include/stream.h" class whitespace { char filler; }; class ostream: File { public: File::open; File::close; File::initialize; File::remove; File::filedesc; File::is_open; File::raw; File::quiet; File::verbose; File::iocount; File::error; File::name; File::setname; File::rdstate; File::eof; File::fail; File::bad; File::good; File::clear; File::failif; File::setbuf; File::writable; File::readable; File::put; File::form; File::flush; ostream() {} ostream(const char* filename, io_mode m, access_mode a) :(filename, m, a) {} ostream(const char* filename, const char* m) :(filename, m) {} ostream(int filedesc, io_mode m) :(filedesc, m) {} ostream( struct _iobuf * fileptr) :(fileptr) {} ~ostream() {} void* ostream::operator void*() { return((fail())?0:this); } ostream& operator<<(char c) { put(c); return(*this);} ostream& operator<<(short n) { form("%d",(int)n); return(*this);} ostream& operator<<(int n) { form("%d",n); return(*this);} ostream& operator<<(long n) { form("%ld",n); return(*this);} ostream& operator<<(float n) { form("%g",(double)n);return(*this);} ostream& operator<<(double n) { form("%g",n); return(*this);} ostream& operator<<(const char* s) { put(s); return(*this);} }; class istream: File { public: File::open; File::close; File::initialize; File::remove; File::filedesc; File::is_open; File::raw; File::quiet; File::verbose; File::iocount; File::error; File::name; File::setname; File::rdstate; File::eof; File::fail; File::bad; File::good; File::clear; File::failif; File::setbuf; File::writable; File::readable; File::get; File::unget; File::scan; File::putback; istream() {} istream(const char* filename, io_mode m, access_mode a) :(filename, m, a) {} istream(const char* filename, const char* m) :(filename, m) {} istream(int filedesc, io_mode m) :(filedesc, m) {} istream( struct _iobuf * fileptr) :(fileptr) {} ~istream() {} void* operator void*() { return((fail())?0:this); } istream& operator>>(char& c) { get(c); return(*this); } istream& operator>>(short& n) { scan("%hd", &n); return(*this); } istream& operator>>(int& n) { scan("%d", &n); return(*this); } istream& operator>>(long& n) { scan("%ld", &n); return(*this); } istream& operator>>(float& n) { scan("%f", &n); return(*this); } istream& operator>>(double& n) { scan("%lf", &n); return(*this); } istream& operator>>(char* s) { scan("%s", s); return(*this); } istream& operator>>(whitespace& w); }; extern istream cin; extern ostream cout; extern ostream cerr; extern whitespace WS; # 11 "dlink.cc" # 1 "dlink.h" # 1 "Pix.h" typedef void* Pix; # 14 "dlink.h" class dLink; typedef dLink* dLinkPtr; typedef void* vPtr; class dLink { friend class dList; friend class dList_iterator; dLinkPtr nx; dLinkPtr pr; vPtr data; dLink( vPtr a, dLinkPtr n, dLinkPtr p ); }; inline dLink::dLink( vPtr a, dLinkPtr n = 0, dLinkPtr p = 0 ) { data = a; nx = n; pr = p; } class dList { friend class dList_iterator; dLinkPtr last; public: dList(); dList( vPtr a ); dList( dList& x ); ~dList(); dList& operator = ( dList& x ); vPtr operator () ( Pix p ); int empty(); int length(); void clear(); Pix append( vPtr a ); Pix prepend( vPtr a ); void join( dList& x ); vPtr head(); vPtr get_head(); void cut_head(); vPtr foot(); vPtr get_foot(); void cut_foot(); Pix first(); Pix last(); void next( Pix& p ); void prev( Pix& p ); int owns( Pix p ); Pix put_after( Pix p, vPtr a ); Pix put_before( Pix p, vPtr a ); void cut( Pix& p, int dir = 1 ); void error( char *msg ); int ok(); }; inline dList::dList() { last = 0 ; } inline dList::dList( vPtr a ) { last = new dLink( a, 0 , 0 ); last->nx = last->pr = last; } inline dList::~dList() { clear(); } inline int dList::empty() { return( last == 0 ); } inline int dList::length() { for (int n = 0, dLinkPtr t = last ; t != last && t != 0 ; ) { ++n; t= t->nx; } return( n ); } inline void dList::next( Pix& p ) { p = (p == 0 || p == last) ? 0 : Pix(((dListPtr)p)->nx); } inline void dList::prev( Pix& p ) { p = (p == 0 || p == last->nx) ? 0 : Pix(((dListPtr)p)->pr); } inline Pix dList::first() { return( (last == 0 ) ? 0 : Pix( last->nx ) ); } inline Pix dList::last() { return( Pix( last ) ); } inline vPtr dList::head() { if (last == 0 ) error( "front: empty list" ); return( last->nx.data ); } inline vPtr dList::foot() { if (last == 0 ) error( "foot: empty list" ); return( last.data ); } # 12 "dlink.cc" void dList:error( char *msg ) { cerror << "\nll: " << msg << "\n"; } dList::dList( dList& x ) { if (x.last == 0 ) last = 0 ; else { dLinkPtr p = x.nx dLinkPtr t = new dLink( p->data ); last = t; p = p->fd; while (p != x.nx) { dLinkPtr n = new dLink( p->data ); t->nx = n; n->pr = t; p = p->nx; } t->nx = last; last->bk = t; last = t; } } void dList::clear() { if (last == 0 ) return; if ((dLinkPtr q = last.nx) == 0 ) { error( "clear: last.nx is NULL" ); exit( 1 ); } dLinkPtr p = last; last = 0 ; while (p != q) { dLinkPtr r = p; p = p->pr; r->nx = r->pr = 0 ; delete( r ); } p->nx = p->pr = 0 ; delete( p ); } Pix dList::append( vPtr a ) { if (last) { dLinkPtr t = new dLinkPtr( a, last->nx, last ); last->nx = (last->nx).pr = t; last = t; } else { dLinkPtr t = new dLinkPtr( a ); last = t->nx = t->pr = t; } return( Pix( t ) ); } Pix dList::prepend( vPtr a ) { if (last) { dLinkPtr t = new dLinkPtr( a, last->nx, last ); last->nx = (last->nx).pr = t; } else { dLinkPtr t = new dLinkPtr( a ); last = t->nx = t->pr = t; } return( Pix( t ) ); } void dList::join( dList& x ) { if (last) { dLinkPtr t = last->nx; last->nx = x.last->nx; (x.last->nx).pr = last; last = x.last; last->nx = t; (last->nx).pr = last; x.last = 0 ; } else { last = x.last; x.last = 0 ; } } int dList::owns( Pix p ) { if (last == 0 || p == 0 || (dLinkPtr t = last->nx) == 0 ) return( 0 ); do { if (Pix( t ) == p) return( 1 ); t = t->fd; } while (t != last->nx ); return( 0 ); } void dList::cut( Pix& p, int dir = 1 ) { if (p == 0) { error( "cut: pix == 0" ); exit( 1 ); } dLinkPtr t = dLinkPtr( p ); if (t->fd == t) { last = 0 : p = 0; } else { if (dir < 0) { if (t == last->nx) p = 0; else p = Pix( t->pr ); } else { if (t == last) p = 0; else p = Pix( t->nx ); } t->pr->nx = t->nx; t->nx->pr = t->pr; if (t == last) last = t->pr; } t->nx = t->pr = 0 ; delete t; } vPtr dList::get_head() { if (last == 0 ) { error( "get_head: empty list" ); exit( 1 ); } dLinkPtr t = last->nx; vPtr datPtr = t->data; if (t->fd = t) last = 0 ; else { t->pr->nx = t->nx; t->nx->pr = t->pr; } t->nx = t->pr = 0 ; delete t; return datPtr; } void dList::cut_head() { if (last == 0 ) { error( "cut_head: empty list" ); exit( 1 ); } dLinkPtr t = last->nx; if (t->fd = t) last = 0 ; else { t->pr->nx = t->nx; t->nx->pr = t->pr; } t->nx = t->pr = 0 ; delete t; } vPtr dList::get_foot() { if (last == 0 ) { error( "get_foot: empty list" ); exit( 1 ); } dLinkPtr t = last; vPtr datPtr = t->data; if (t->fd = t) last = 0 ; else { t->pr->nx = t->nx; t->nx->pr = t->pr; last = t->ptr; } t->nx = t->pr = 0 ; delete t; return datPtr; } void dList::cut_foot() { if (last == 0 ) { error( "cut_foot: empty list" ); exit( 1 ); } dLinkPtr t = last; if (t->fd = t) last = 0 ; else { t->pr->nx = t->nx; t->nx->pr = t->pr; last = t->ptr; } t->nx = t->pr = 0 ; delete t; } int dList::OK() { int v = 1; if (last) { dLinkPtr t = last->nx; long count = MAXLONG; do { count--; v &= t->pr->nx == t; v &= t->nx->pr == t; t = t->nx } while (v && count > 0 && t != last->nx); v &= count > 0; } if (!v) error( "OK: failed" ); return( v ); }