internal compiler error when turning on optimization (3/3)

Marat Boshernitsan maratb@CS.Berkeley.EDU
Mon Mar 9 01:06:00 GMT 1998


    ostream& operator<<(bool b) { return operator<<((int)b); }

    ostream& operator<<(double n);
    ostream& operator<<(float n) { return operator<<((double)n); }

    ostream& operator<<(long double n);



    ostream& operator<<(__omanip func) { return (*func)(*this); }
    ostream& operator<<(__manip func) {(*func)(*this); return *this;}
    ostream& operator<<(streambuf*);

    streambuf* ostreambuf() const { return _strbuf; }

};

class istream : virtual public ios
{
     
protected:
    size_t   _gcount;

    int _skip_ws();
  public:
    istream(): _gcount (0) { }
    istream(streambuf* sb, ostream*tied= (__null) );
    istream& get(char* ptr, int len, char delim = '\n');
    istream& get(unsigned char* ptr, int len, char delim = '\n')
	{ return get((char*)ptr, len, delim); }
    istream& get(char& c);
    istream& get(unsigned char& c) { return get((char&)c); }
    istream& getline(char* ptr, int len, char delim = '\n');
    istream& getline(unsigned char* ptr, int len, char delim = '\n')
	{ return getline((char*)ptr, len, delim); }
    istream& get(signed char& c)  { return get((char&)c); }
    istream& get(signed char* ptr, int len, char delim = '\n')
	{ return get((char*)ptr, len, delim); }
    istream& getline(signed char* ptr, int len, char delim = '\n')
	{ return getline((char*)ptr, len, delim); }
    istream& read(char *ptr, streamsize n);
    istream& read(unsigned char *ptr, streamsize n)
      { return read((char*)ptr, n); }
    istream& read(signed char *ptr, streamsize n)
      { return read((char*)ptr, n); }
    istream& read(void *ptr, streamsize n)
      { return read((char*)ptr, n); }
    istream& get(streambuf& sb, char delim = '\n');
    istream& gets(char **s, char delim = '\n');
    int ipfx(int need = 0) {
	if (!good()) { set(ios::failbit); return 0; }
	else {
	   ;
	  if (_tie && (need == 0 || rdbuf()->in_avail() < need)) _tie->flush();
	  if (!need && (flags() & ios::skipws)) return _skip_ws();
	  else return 1;
	}
    }
    int ipfx0() {  
	if (!good()) { set(ios::failbit); return 0; }
	else {
	   ;
	  if (_tie) _tie->flush();
	  if (flags() & ios::skipws) return _skip_ws();
	  else return 1;
	}
    }
    int ipfx1() {  
	if (!good()) { set(ios::failbit); return 0; }
	else {
	   ;
	  if (_tie && rdbuf()->in_avail() == 0) _tie->flush();
	  return 1;
	}
    }
    void isfx() {  ; }
    int get() { if (!ipfx1()) return (-1) ;
		else { int ch = _strbuf->sbumpc();
		       if (ch == (-1) ) set(ios::eofbit);
		       return ch;
		     } }
    int peek();
    size_t   gcount() { return _gcount; }
    istream& ignore(int n=1, int delim = (-1) );
    int sync ();
    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, __gnuc_va_list  args);

    istream& unget(char ch) { return putback(ch); }
    int skip(int i);
    streambuf* istreambuf() const { return _strbuf; }


    istream& operator>>(char*);
    istream& operator>>(unsigned char* p) { return operator>>((char*)p); }
    istream& operator>>(signed char*p) { return operator>>((char*)p); }
    istream& operator>>(char& c);
    istream& operator>>(unsigned char& c) {return operator>>((char&)c);}
    istream& operator>>(signed char& c) {return operator>>((char&)c);}
    istream& operator>>(int&);
    istream& operator>>(long&);

    __extension__ istream& operator>>(long long&);
    __extension__ istream& operator>>(unsigned long long&);

    istream& operator>>(short&);
    istream& operator>>(unsigned int&);
    istream& operator>>(unsigned long&);
    istream& operator>>(unsigned short&);

    istream& operator>>(bool&);

    istream& operator>>(float&);
    istream& operator>>(double&);
    istream& operator>>(long double&);
    istream& operator>>( __manip func) {(*func)(*this); return *this;}
    istream& operator>>(__imanip func) { return (*func)(*this); }
    istream& operator>>(streambuf*);
};

class iostream : public istream, public ostream
{
  public:
    iostream() { }
    iostream(streambuf* sb, ostream*tied= (__null) );
};

class _IO_istream_withassign : public istream {
public:
  _IO_istream_withassign& operator=(istream&);
  _IO_istream_withassign& operator=(_IO_istream_withassign& rhs)
    { return operator= (static_cast<istream&> (rhs)); }
};

class _IO_ostream_withassign : public ostream {
public:
  _IO_ostream_withassign& operator=(ostream&);
  _IO_ostream_withassign& operator=(_IO_ostream_withassign& rhs)
    { return operator= (static_cast<ostream&> (rhs)); }
};

extern _IO_istream_withassign cin;
 
extern _IO_ostream_withassign cout, cerr;

extern _IO_ostream_withassign clog



;

extern istream& lock(istream& ins);
extern istream& unlock(istream& ins);
extern ostream& lock(ostream& outs);
extern ostream& unlock(ostream& outs);

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


# 33 "/home/local/include/g++/stream.h" 2 3


extern "C++" {
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);

char*        chr(char ch, int width = 0);
char*        str(const char* s, int width = 0);

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


# 15 "EditReport.cc" 2

# 1 "/usr/include/assert.h" 1 3
 

















 



# 32 "/usr/include/assert.h" 3





 




# 56 "/usr/include/assert.h" 3


extern "C" { 

 
extern void __assert_fail  (__const char *__assertion,
				__const char *__file,
				unsigned int __line,
				__const char *__function)  
     __attribute__ ((__noreturn__));

 
extern void __assert_perror_fail  (int __errnum,
				       __const char *__file,
				       unsigned int __line,
				       __const char *__function)  
     __attribute__ ((__noreturn__));

} 













 











# 16 "EditReport.cc" 2


static const char RCSid[] = "$Source: /home/orodruin/d/ensemble/work/maratb/src/common/RCS/EditReport.cc,v $ $Revision: 1.5 $ $Date: 1995/12/05 01:03:43 $";

void debug_abort() {
  abort();
}

 
 
 

EditReport::EditReport()
: l(0), size(0), ed((__null) ) {}

EditReport::EditReport(const EditReport *other)
: l(other->l), size(other->size), ed(new Edit [other->size]) {
    for (int i=0; i<l; i++)
	ed[i] = other->ed[i];
}

EditReport::~EditReport() {
    delete ed;
}

 
void EditReport::realloc() {
    if (size == 0) {
	size = 4;
	ed = new Edit[size];
    } else {
	size <<= 1;
	Edit *ned = new Edit[size];
	for (int i=0; i<l; i++) ned[i] = ed[i];
	delete ed;
	ed = ned;
    }
}

void EditReport::add_edit(Type type, void *element, int pos) {
    if (l == size) realloc();
    ed[l].type = type;
    ed[l].element = element;
    ed[l].pos = pos;
    l++;
}

EditReport *EditReport::verify() {
    for (int i=0; i<length(); i++) {
	const Edit *ed = edit(i);
	((void) (( (ed->type == Insert) || (ed->type == Delete) ) ? 0 :	(__assert_fail ("(ed->type == Insert) || (ed->type == Delete)" ,	"EditReport.cc", 66, __PRETTY_FUNCTION__ ), 0))) ;
    }
    return this;
}

 
 
 

 
 
class ReportArray {
  public:
     
    ReportArray(int fromlen, int tolen, bool permit_change)
    : _permit_change(permit_change) {
	step = fromlen + 1;
	size = (fromlen+1) * (tolen+1);
	array = new EditReport* [size];
	EditReport **ptr = array, **ceiling = array + size;
	while (ptr < ceiling) *ptr++ = (__null) ;
	lsize = 8;
	llen = 0;
	list = new EditReport* [lsize];
    }

     
    ~ReportArray() {
	EditReport *retval = array[size-1];
	for (int i=0; i<llen; i++) {
	    EditReport *l = list[i];
	    if (l != retval) delete l;
	}
	delete list;
	delete array;
    }

     
    EditReport *val(int from, int to) {
	return array[from + (to*step)];
    }
    void set_val(int from, int to, EditReport *er) {
	array[from + (to*step)] = er;
    }

     
    void add_to_list(EditReport *er) {
	if (llen == lsize) {
	    lsize <<= 1;
	    EditReport **newlist = new EditReport* [lsize];
	    for (int i=0; i<llen; i++)
		newlist[i] = list[i];
	    delete list;
	    list = newlist;
	}
	list[llen++] = er;
    }

     
    bool permit_change() const { return _permit_change; }

  private:
    int step, size;
    EditReport **array;
    EditReport **list;
    int lsize, llen;
    bool _permit_change;
};

 
static EditReport *min_edit_distance(int fromlen, void **from,
				     int tolen, void **to,
				     ReportArray &ra) {
     
    EditReport *er = ra.val(fromlen, tolen);
    if (er) return er;

     

    int lastfrom = fromlen-1;
    int lastto = tolen-1;

     
    if (fromlen == 0) {
	 
	if (tolen == 0) {
	    er = new EditReport;
	    ra.add_to_list(er);
	}
	 
	else {
	    er = new EditReport(min_edit_distance(fromlen, from,
						  lastto, to, ra));
	    ra.add_to_list(er);
	    er->add_edit(EditReport::Insert, to[lastto], lastto);
	}
    }
    else if (tolen == 0) {
	 
	er = new EditReport(min_edit_distance(lastfrom, from,
					      tolen, to, ra));
	ra.add_to_list(er);
	er->add_edit(EditReport::Delete, from[lastfrom], lastfrom);
    }
    else {
	 
	 
	 
	 
	 
	 
	const EditReport *shorter_to =
	    min_edit_distance(fromlen, from, lastto, to, ra);
	int stlen = shorter_to->length() + 1;
	const EditReport *shorter_from =
	    min_edit_distance(lastfrom, from, tolen, to, ra);
	int sflen = shorter_from->length() + 1;

	 
	 
	 
	 
	EditReport *diag = min_edit_distance(lastfrom, from,
					     lastto, to, ra);
	if (from[lastfrom] == to[lastto]) {
	     
	    if ((diag->length() <= stlen) &&
		(diag->length() <= sflen)) {
		er = diag;		 
		goto save_er;
	    }
	} else if (ra.permit_change()) {
	    int len = diag->length() + 1;
	    if ((len <= stlen) && (len <= sflen)) {
		 
		 
		er = new EditReport(diag);
		ra.add_to_list(er);
		er->add_edit(EditReport::Change, to[lastto], lastto);
		goto save_er;
	    }
	}

	 

	if (stlen < sflen) {
	     
	    er = new EditReport(shorter_to);
	    ra.add_to_list(er);
	    er->add_edit(EditReport::Insert, to[lastto], lastto);
	}
	else {
	     
	    er = new EditReport(shorter_from);
	    ra.add_to_list(er);
	    er->add_edit(EditReport::Delete, from[lastfrom], tolen);
	}
    }

     
  save_er:
    ra.set_val(fromlen, tolen, er);
    return er;
}

 
 
EditReport *min_edit_distance(int fromlen, void **from,
			      int tolen, void **to,
			      bool permit_change) {
    ReportArray ra(fromlen, tolen, permit_change);
    return min_edit_distance(fromlen, from, tolen, to, ra);
}

 
ostream &operator<<(ostream &out, const EditReport &er) {
    out << "  EditReport @" << (void *) &er << ": "
	<< er.length() << " edits\n";
    for (int i=0; i<er.length(); i++) {
	const EditReport::Edit *ed = er.edit(i);
	switch (ed->type) {
	  case EditReport::Insert:
	    out << "    insert ";
	    break;
	  case EditReport::Delete:
	    out << "    delete ";
	    break;
	  case EditReport::Change:
	    out << "    change ";
	    break;
	  default:
	    debug_abort();
	}
	out << ed->element << " @" << ed->pos << '\n';
    }
    return out;
}

void EditReport::print() {
    cout << *this;
}

--Multipart_Mon_Mar__9_00:48:38_1998-1--



More information about the Gcc-bugs mailing list