From: lewis@sophists.COM
Subject: -O flag causes gcc 2.3.1 to crash
Organization: GNUs Not Usenet
Distribution: gnu
Date: Mon, 9 Nov 1992 11:33:11 GMT

The enclosed bit of C++ code compiles fine with optimization turned off,
but with "-O" it procudes the output:
        /usr/local/bin/gcc: Internal compiler error: program cc1plus got fatal signal 6

Slight tweeks produce the error:
        BUG.c:1442: virtual memory exhausted
or:
        /usr/local/bin/gcc: Internal compiler error: program cc1plus got fatal signal 11

On my machine (a 68k running sys v, rel 2.2)  SIGIOT=6, SIGABRT=6, and SIGSEGV== 11.


Sorry I could not shrink the size of the example more than I have - most reductions
make the problem go away.

I am posting this to the G++ bug list since it is C++ code that causes the problem,
but also to the gcc bug list since it seems to be a back-end problem.


typedef unsigned int size_t;
enum	Bool { False, True };

typedef	unsigned	long	UInt32;
typedef	long				Int32;

UInt32	kMinUInt32	=	0;
UInt32	kMaxUInt32	=	4294967295 ;
Int32	kMinInt32	=	-2147483648 ;
Int32	kMaxInt32	=	2147483647 ;

size_t	kMinSize_T	=	size_t (kMinUInt32);
size_t	kMaxSize_T	=	size_t (kMaxUInt32);


void _Assert ( char* assertType,  char* expression,  char* file, int lineNumber);


class	Ch	{
	public:
		Ch (char c);		 
		Ch ( Ch& from);

		 	 Ch&	operator= ( Ch& rhs);

		 	char	GetAsciiCode () ;

	private:
		char	fChCode;
};

Bool	operator== (Ch lhs, Ch rhs);
Bool	operator!= (Ch lhs, Ch rhs);
Bool	operator>= (Ch lhs, Ch rhs);
Bool	operator> (Ch lhs, Ch rhs);
Bool	operator<= (Ch lhs, Ch rhs);
Bool	operator< (Ch lhs, Ch rhs);


 



enum	SqDirection {
	eSqForward,
	eSqBackward,
};

size_t	kBadSqIndex	=	kMaxSize_T;

 
enum AddMode {
	ePrepend = 1,
	eAppend = -1,
};



typedef	UInt32		Counter_Sh;			 
extern	Counter_Sh*		sCounterList_Sh;
extern	void				GetMem_Sh ();
	

class	StRep {
	protected:
		StRep ();
		
	public:
		virtual	~StRep ();

		virtual	StRep*	Clone () 		= 0 ;
			virtual	size_t	GetLength ()  						= 0 ;
		virtual	Bool	Contains (Ch item) 					= 0 ;
			virtual	void	RemoveAll () 									= 0 ;

		virtual	Ch	GetAt (size_t index) 				= 0 ;
		virtual	void		SetAt (Ch item, size_t index)	= 0 ;
		virtual	void		InsertAt (Ch item, size_t index)	= 0 ;
		virtual	void		RemoveAt (size_t index, size_t amountToRemove)	= 0 ;
			virtual	void	SetLength (size_t newLength) 	= 0 ;
			virtual	 void*	Peek ()  						= 0 ;
};



 class  ShOfStRep    {
	private:
		ShOfStRep    ();	
	public:
		ShOfStRep    (StRep* (*cloneFunction) ( StRep&), StRep* ptr);			ShOfStRep    ( ShOfStRep   & src);

		~ShOfStRep    ();											
		 	ShOfStRep   & operator= ( ShOfStRep   & src);
		 	ShOfStRep   & operator= (StRep* ptr);

		
		 	 StRep*	operator-> () ;
		 	 StRep&	operator* () ;


		
		typedef	UInt32	Counter;
		 	Counter	CountReferences () 	{ 			(((fCount)!=0 ) ? (void) 0 : _Assert ("Assertion", "(fCount)!=Nil", "../../../../Library/Foundation/Templates//ShOfStRep.hh", 55))  ; return (*fCount); }


		
		 	 StRep*	GetPointer () 		{ return (fPtr); }

		
		 	void	Assure1Reference ()	{ if (CountReferences () != 1) { BreakReferences (); } }

	private:
		StRep*			fPtr;							Counter*	fCount;							StRep*			(*fCloner) ( StRep&);	
		 	void	BreakReferences ();
};

inline	Bool	operator== ( ShOfStRep   & lhs,  ShOfStRep   & rhs)
{
	return (Bool (lhs.GetPointer () == rhs.GetPointer ()));
}

inline	Bool	operator!= ( ShOfStRep   & lhs,  ShOfStRep   & rhs)
{
	return (Bool (lhs.GetPointer () != rhs.GetPointer ()));
}



class	St {
	public:
		St ();
		St ( char* cSt);
		St ( void* ArOfBytes, size_t nBytes);	 
		St ( St& from);

		~St ()	{}		 

		 	St&	operator= ( St& newSt);

		 	St&	operator+= (Ch appendage);
		 	St&	operator+= ( St& appendage);

		 	size_t	GetLength () ;
		 	void			SetLength (size_t newLength);

		 	Ch	operator[] (size_t i) ;
		 	void		SetCharAt (Ch c, size_t i);
		
		 	void		InsertAt (Ch c, size_t i);
		 	void		RemoveAt (size_t i);
		 	void		RemoveAt (size_t i, size_t amountToRemove);
		 	void		Remove (Ch c);

		 




		 	size_t	IndexOf (Ch c) ;
		 	size_t	IndexOf ( St& subSt) ;
		 	size_t	RIndexOf (Ch c) ;
		 	size_t	RIndexOf ( St& subSt) ;
		 	Bool			Contains (Ch c) ;
		 	Bool			Contains ( St& subSt) ;

		 



		 	St		SubSt (size_t from, size_t length = kBadSqIndex) ;

		 	 void* Peek () ;

		 	char*	ToCSt () ;
		 	char*	ToCSt (char buf [], size_t bufferSize) ;
		 	char*	ToCStTrunc (char buf [], size_t bufferSize) ;

	protected:
		St (StRep* ShPart, Bool ignored);	 
		
		 	void	SetRep (StRep* rep)	{ fRep = rep; }

		 	 StRep*	GetRep () 	{ return (fRep.GetPointer ()); }

	private:		

		ShOfStRep   	fRep;


		static	StRep*	Clone ( StRep& rep)	{ return (rep.Clone ()); }

	 
	friend	Bool	operator== ( St& lhs,  St& rhs);
	friend	Bool	operator!= ( St& lhs,  St& rhs);
	friend	Bool	operator< ( St& lhs,  St& rhs);
	friend	Bool	operator<= ( St& lhs,  St& rhs);
	friend	Bool	operator> ( St& lhs,  St& rhs);
	friend	Bool	operator>= ( St& lhs,  St& rhs);
	friend	St	operator+ ( St& lhs,  St& rhs);
};


St	operator+ ( St& lhs,  St& rhs);

Bool	operator== ( St& lhs,  St& rhs);


class 	ItRepOfSt   ;
class 	ItOfSt    {
	public:
		ItOfSt    (ItRepOfSt   * it);
		ItOfSt    ( ItOfSt   & from);
		~ItOfSt    ();

		 	ItOfSt   &	operator= ( ItOfSt   & rhs);

	private:
		ItOfSt    ();	
	public:
		 	Bool	Done () ;
		 	void	Next ();
		 	St		Current () ;

	protected:
		ItRepOfSt   *	fIt;
};


 class 	ItRepOfSt    {
	protected:
		ItRepOfSt    ();

	public:
		virtual	~ItRepOfSt    ();

	
	public:
		virtual	Bool			Done () 			=	0 ;
		virtual	void			Next ()					=	0 ;
		virtual	St				Current () 		=	0 ;

		virtual	ItRepOfSt   *	Clone () 			=	0 ;
};


	
 class 	SqRepOfSt   ;
 class 	SqItRepOfSt   ;
 class 	SqMutatorRepOfSt   ;

	

 class  ShOfSqRepOfSt       {
	private:
		ShOfSqRepOfSt       ();	
	public:
		ShOfSqRepOfSt       (SqRepOfSt   * (*cloneFunction) ( SqRepOfSt   &), SqRepOfSt   * ptr);			ShOfSqRepOfSt       ( ShOfSqRepOfSt      & src);

		~ShOfSqRepOfSt       ();											
		 	ShOfSqRepOfSt      & operator= ( ShOfSqRepOfSt      & src);
		 	ShOfSqRepOfSt      & operator= (SqRepOfSt   * ptr);

		
		 	 SqRepOfSt   *	operator-> () ;
		 	 SqRepOfSt   &	operator* () ;


		
		typedef	UInt32	Counter;
		 	Counter	CountReferences () 	{ 			(((fCount)!=0 ) ? (void) 0 : _Assert ("Assertion", "(fCount)!=Nil", "./ShOfSqRepOfSt.hh", 58))  ; return (*fCount); }


		
		 	 SqRepOfSt   *	GetPointer () 		{ return (fPtr); }

		
		 	void	Assure1Reference ()	{ if (CountReferences () != 1) { BreakReferences (); } }

	private:
		SqRepOfSt   *			fPtr;							Counter*	fCount;							SqRepOfSt   *			(*fCloner) ( SqRepOfSt   &);	
		 	void	BreakReferences ();
};

 class 	SqOfSt    {
	public:
		SqOfSt    ();
		SqOfSt    ( SqOfSt   & src);
		SqOfSt    ( St* items, size_t size);

	protected:
		SqOfSt    (SqRepOfSt   * rep);

	public:
		 	SqOfSt   & operator= ( SqOfSt   & src);

	public:
		 	size_t	GetLength () ;
		 	Bool	IsEmpty () ;
		 	Bool	Contains (St item) ;
		 	void	RemoveAll ();
		 	void	Compact ();

		 	St		GetAt (size_t index) ;
		 	void	SetAt (St item, size_t index);

		 	St		operator[] (size_t index) ;

		
		 	size_t	IndexOf (St item) ;
		 	size_t	IndexOf ( SqOfSt   & s) ;

		
		 	void	InsertAt (St item, size_t index);
		 	void	InsertAt ( SqOfSt   & items, size_t index);

		 	void	Prepend (St item);
		 	void	Prepend ( SqOfSt   & items);
		 	void	Append (St item);
		 	void	Append ( SqOfSt   & items);

		 	SqOfSt   &	operator+= (St item);
		 	SqOfSt   &	operator+= ( SqOfSt   & items);

		
		 	void	RemoveAt (size_t index);
		 	void	RemoveAt (size_t index, size_t amountToRemove);

		
		 	void	Remove (St item);
		 	void	Remove ( SqOfSt   & items);

		 	SqOfSt   &	operator-= (St item);
		 	SqOfSt   &	operator-= ( SqOfSt   & items);

		 	operator ItRepOfSt   * () ;
		 	SqItRepOfSt   *		MakeSqIt (SqDirection d) ;
		 	SqMutatorRepOfSt   *		MakeSqMutator (SqDirection d);
		 	operator SqItRepOfSt   * () ;
		 	operator SqMutatorRepOfSt   * ();

	protected:
		 	void	AddItems ( St* items, size_t size);

		 	 SqRepOfSt   *	GetRep () ;

	private:
		ShOfSqRepOfSt       	fRep;

		static	SqRepOfSt   *	Clone ( SqRepOfSt   & rep);

	friend	Bool	operator== ( SqOfSt   & lhs,  SqOfSt   & rhs);
};

Bool	operator== ( SqOfSt   & lhs,  SqOfSt   & rhs);
Bool	operator!= ( SqOfSt   & lhs,  SqOfSt   & rhs);

SqOfSt   	operator+ ( SqOfSt   & lhs,  SqOfSt   & rhs);
SqOfSt   	operator- ( SqOfSt   & lhs,  SqOfSt   & rhs);

 class 	SqItOfSt    : public ItOfSt    {
	public:
		SqItOfSt    (SqItRepOfSt   * it);

		 	size_t				CurrentIndex ()	;
		 	SqDirection	GetDirection () ;
};

 class 	SqMutatorOfSt    : public SqItOfSt    {
	public:
		SqMutatorOfSt    (SqMutatorRepOfSt   * it);

		 	void	RemoveCurrent ();
		 	void	UpdateCurrent (St newValue);
};

 class 	SqRepOfSt    {
	protected:
		SqRepOfSt    ();

	public:
		virtual ~SqRepOfSt    ();

	public:
		virtual	SqRepOfSt   *	Clone () 										=	0 ;
		virtual	size_t			GetLength ()  									=	0 ;
		virtual	void			Compact ()											=	0 ;
		virtual	void			RemoveAll () 										=	0 ;

		virtual	St				GetAt (size_t index) 							=	0 ;
		virtual	void			SetAt (St item, size_t index)						=	0 ;
		virtual	void			InsertAt (St item, size_t index)						=	0 ;
		virtual	void			RemoveAt (size_t index, size_t amountToRemove)		=	0 ;
		virtual	void			Remove (St item)										=	0 ;

		virtual	ItRepOfSt   * 		MakeIt () 							=	0 ;
		virtual	SqItRepOfSt   *	MakeSqIt (SqDirection d)	=	0 ;
		virtual	SqMutatorRepOfSt   *	MakeSqMutator (SqDirection d)	=	0 ;
};

 class 	SqItRepOfSt    : public ItRepOfSt    {
	protected:
		SqItRepOfSt    ();

	public:
		virtual	size_t				CurrentIndex ()		=	0 ;
		virtual	SqDirection	GetDirection () 	=	0 ;
};

struct	ID {
	ID ();
							 
	Bool			fBangDep;
	Bool			fBangBang;
	St			fName;
	SqOfSt   	fArguments;		  
};
 
inline Bool operator == ( ID& lhs,  ID& rhs) { return Bool ((lhs.fName == rhs.fName) &&  (lhs.fArguments == rhs.fArguments)); }


 class 	ItRepOfID   ;
 class 	ItOfID    {
	public:
		ItOfID    (ItRepOfID   * it);
		ItOfID    ( ItOfID   & from);
		~ItOfID    ();

		 	ItOfID   &	operator= ( ItOfID   & rhs);

	private:
		ItOfID    ();	
	public:
		 	Bool	Done () ;
		 	void	Next ();
		 	ID		Current () ;

	protected:
		ItRepOfID   *	fIt;
};




 class 	ItRepOfID    {
	protected:
		ItRepOfID    ();

	public:
		virtual	~ItRepOfID    ();

	
	public:
		virtual	Bool			Done () 			=	0 ;
		virtual	void			Next ()					=	0 ;
		virtual	ID				Current () 		=	0 ;

		virtual	ItRepOfID   *	Clone () 			=	0 ;
};


	
 class 	SqRepOfID   ;
 class 	SqItRepOfID   ;
 class 	SqMutatorRepOfID   ;
 class  ShOfSqRepOfID       {
	private:
		ShOfSqRepOfID       ();	
	public:
		ShOfSqRepOfID       (SqRepOfID   * (*cloneFunction) ( SqRepOfID   &), SqRepOfID   * ptr);			ShOfSqRepOfID       ( ShOfSqRepOfID      & src);

		~ShOfSqRepOfID       ();											
		 	ShOfSqRepOfID      & operator= ( ShOfSqRepOfID      & src);
		 	ShOfSqRepOfID      & operator= (SqRepOfID   * ptr);

		
		 	 SqRepOfID   *	operator-> () ;
		 	 SqRepOfID   &	operator* () ;


		
		typedef	UInt32	Counter;
		 	Counter	CountReferences () 	{ 			(((fCount)!=0 ) ? (void) 0 : _Assert ("Assertion", "(fCount)!=Nil", "./ShOfSqRepOfID.hh", 55))  ; return (*fCount); }

		
		 	 SqRepOfID   *	GetPointer () 		{ return (fPtr); }

		
		 	void	Assure1Reference ()	{ if (CountReferences () != 1) { BreakReferences (); } }

	private:
		SqRepOfID   *			fPtr;							Counter*	fCount;							SqRepOfID   *			(*fCloner) ( SqRepOfID   &);	
		 	void	BreakReferences ();
};



 class 	SqOfID    {
	public:
		SqOfID    ();
		SqOfID    ( SqOfID   & src);
		SqOfID    ( ID* items, size_t size);

	protected:
		SqOfID    (SqRepOfID   * rep);

	public:
		 	SqOfID   & operator= ( SqOfID   & src);

	public:
		 	size_t	GetLength () ;
		 	Bool	IsEmpty () ;
		 	Bool	Contains (ID item) ;
		 	void	RemoveAll ();
		 	void	Compact ();

		 	ID		GetAt (size_t index) ;
		 	void	SetAt (ID item, size_t index);

		 	ID		operator[] (size_t index) ;

		
		 	size_t	IndexOf (ID item) ;
		 	size_t	IndexOf ( SqOfID   & s) ;

		
		 	void	InsertAt (ID item, size_t index);
		 	void	InsertAt ( SqOfID   & items, size_t index);

		 	void	Prepend (ID item);
		 	void	Prepend ( SqOfID   & items);
		 	void	Append (ID item);
		 	void	Append ( SqOfID   & items);

		 	SqOfID   &	operator+= (ID item);
		 	SqOfID   &	operator+= ( SqOfID   & items);

		
		 	void	RemoveAt (size_t index);
		 	void	RemoveAt (size_t index, size_t amountToRemove);

		
		 	void	Remove (ID item);
		 	void	Remove ( SqOfID   & items);

		 	SqOfID   &	operator-= (ID item);
		 	SqOfID   &	operator-= ( SqOfID   & items);

		 	operator ItRepOfID   * () ;
		 	SqItRepOfID   *		MakeSqIt (SqDirection d) ;
		 	SqMutatorRepOfID   *		MakeSqMutator (SqDirection d);
		 	operator SqItRepOfID   * () ;
		 	operator SqMutatorRepOfID   * ();

	protected:
		 	void	AddItems ( ID* items, size_t size);

		 	 SqRepOfID   *	GetRep () ;

	private:
		ShOfSqRepOfID       	fRep;

		static	SqRepOfID   *	Clone ( SqRepOfID   & rep);

	friend	Bool	operator== ( SqOfID   & lhs,  SqOfID   & rhs);
};

Bool	operator== ( SqOfID   & lhs,  SqOfID   & rhs);
Bool	operator!= ( SqOfID   & lhs,  SqOfID   & rhs);

SqOfID   	operator+ ( SqOfID   & lhs,  SqOfID   & rhs);
SqOfID   	operator- ( SqOfID   & lhs,  SqOfID   & rhs);

 class 	SqItOfID    : public ItOfID    {
	public:
		SqItOfID    (SqItRepOfID   * it);

		 	size_t				CurrentIndex ()	;
		 	SqDirection	GetDirection () ;
};

 class 	SqMutatorOfID    : public SqItOfID    {
	public:
		SqMutatorOfID    (SqMutatorRepOfID   * it);

		 	void	RemoveCurrent ();
		 	void	UpdateCurrent (ID newValue);
};

 class 	SqRepOfID    {
	protected:
		SqRepOfID    ();

	public:
		virtual ~SqRepOfID    ();

	public:
		virtual	SqRepOfID   *	Clone () 										=	0 ;
		virtual	size_t			GetLength ()  									=	0 ;
		virtual	void			Compact ()											=	0 ;
		virtual	void			RemoveAll () 										=	0 ;

		virtual	ID				GetAt (size_t index) 							=	0 ;
		virtual	void			SetAt (ID item, size_t index)						=	0 ;
		virtual	void			InsertAt (ID item, size_t index)						=	0 ;
		virtual	void			RemoveAt (size_t index, size_t amountToRemove)		=	0 ;
		virtual	void			Remove (ID item)										=	0 ;

		virtual	ItRepOfID   * 		MakeIt () 							=	0 ;
		virtual	SqItRepOfID   *	MakeSqIt (SqDirection d)	=	0 ;
		virtual	SqMutatorRepOfID   *	MakeSqMutator (SqDirection d)	=	0 ;
};

 class 	SqItRepOfID    : public ItRepOfID    {
	protected:
		SqItRepOfID    ();

	public:
		virtual	size_t				CurrentIndex ()		=	0 ;
		virtual	SqDirection	GetDirection () 	=	0 ;
};

 class 	SqMutatorRepOfID    : public SqItRepOfID    {
	protected:
		SqMutatorRepOfID    ();

	public:
		virtual	void	RemoveCurrent () 			=	0 ;
		virtual	void	UpdateCurrent (ID newValue) 	=	0 ;
};

struct	RR {
	RR () {}		 
								 
		RR ( RR& from):fTemplateName(from.fTemplateName),fShortName(from.fShortName),fArguments(from.fArguments)   {}
		RR& operator=( RR& rhs)
		{
			fTemplateName = rhs.fTemplateName;
			fShortName = rhs.fShortName;
			fArguments = rhs.fArguments;
			return *this;
		}

	St				fTemplateName;
	St				fShortName;
	SqOfSt   	fArguments;
};

inline Bool operator == ( RR& lhs,  RR& rhs) { return Bool ((lhs.fTemplateName == rhs.fTemplateName) &&  (lhs.fShortName == rhs.fShortName)  &&  (lhs.fArguments == rhs.fArguments)); }



 class 	ItRepOfRR   ;
 class 	ItOfRR    {
	public:
		ItOfRR    (ItRepOfRR   * it);
		ItOfRR    ( ItOfRR   & from);
		~ItOfRR    ();

		 	ItOfRR   &	operator= ( ItOfRR   & rhs);

	private:
		ItOfRR    ();	
	public:
		 	Bool	Done () ;
		 	void	Next ();
		 	RR		Current () ;

	protected:
		ItRepOfRR   *	fIt;
};




 class 	ItRepOfRR    {
	protected:
		ItRepOfRR    ();

	public:
		virtual	~ItRepOfRR    ();

	
	public:
		virtual	Bool			Done () 			=	0 ;
		virtual	void			Next ()					=	0 ;
		virtual	RR				Current () 		=	0 ;

		virtual	ItRepOfRR   *	Clone () 			=	0 ;
};


	
 class 	SqRepOfRR   ;
 class 	SqItRepOfRR   ;
 class 	SqMutatorRepOfRR   ;


 class  ShOfSqRepOfRR       {
	private:
		ShOfSqRepOfRR       ();	
	public:
		ShOfSqRepOfRR       (SqRepOfRR   * (*cloneFunction) ( SqRepOfRR   &), SqRepOfRR   * ptr);			ShOfSqRepOfRR       ( ShOfSqRepOfRR      & src);

		~ShOfSqRepOfRR       ();											
		 	ShOfSqRepOfRR      & operator= ( ShOfSqRepOfRR      & src);
		 	ShOfSqRepOfRR      & operator= (SqRepOfRR   * ptr);

		
		 	 SqRepOfRR   *	operator-> () ;
		 	 SqRepOfRR   &	operator* () ;


		
		typedef	UInt32	Counter;
		 	Counter	CountReferences () 	{ 			(((fCount)!=0 ) ? (void) 0 : _Assert ("Assertion", "(fCount)!=Nil", "./ShOfSqRepOfRR.hh", 55))  ; return (*fCount); }


		
		 	 SqRepOfRR   *	GetPointer () 		{ return (fPtr); }

		
		 	void	Assure1Reference ()	{ if (CountReferences () != 1) { BreakReferences (); } }

	private:
		SqRepOfRR   *			fPtr;							Counter*	fCount;							SqRepOfRR   *			(*fCloner) ( SqRepOfRR   &);	
		 	void	BreakReferences ();
};


 class 	SqOfRR    {
	public:
		SqOfRR    ();
		SqOfRR    ( SqOfRR   & src);
		SqOfRR    ( RR* items, size_t size);

	protected:
		SqOfRR    (SqRepOfRR   * rep);

	public:
		 	SqOfRR   & operator= ( SqOfRR   & src);

	public:
		 	size_t	GetLength () ;
		 	Bool	IsEmpty () ;
		 	Bool	Contains (RR item) ;
		 	void	RemoveAll ();
		 	void	Compact ();

		 	RR		GetAt (size_t index) ;
		 	void	SetAt (RR item, size_t index);

		 	RR		operator[] (size_t index) ;

		
		 	size_t	IndexOf (RR item) ;
		 	size_t	IndexOf ( SqOfRR   & s) ;

		
		 	void	InsertAt (RR item, size_t index);
		 	void	InsertAt ( SqOfRR   & items, size_t index);

		 	void	Prepend (RR item);
		 	void	Prepend ( SqOfRR   & items);
		 	void	Append (RR item);
		 	void	Append ( SqOfRR   & items);

		 	SqOfRR   &	operator+= (RR item);
		 	SqOfRR   &	operator+= ( SqOfRR   & items);

		
		 	void	RemoveAt (size_t index);
		 	void	RemoveAt (size_t index, size_t amountToRemove);

		
		 	void	Remove (RR item);
		 	void	Remove ( SqOfRR   & items);

		 	SqOfRR   &	operator-= (RR item);
		 	SqOfRR   &	operator-= ( SqOfRR   & items);

		 	operator ItRepOfRR   * () ;
		 	SqItRepOfRR   *		MakeSqIt (SqDirection d) ;
		 	SqMutatorRepOfRR   *		MakeSqMutator (SqDirection d);
		 	operator SqItRepOfRR   * () ;
		 	operator SqMutatorRepOfRR   * ();

	protected:
		 	void	AddItems ( RR* items, size_t size);

		 	 SqRepOfRR   *	GetRep () ;

	private:
		ShOfSqRepOfRR       	fRep;

		static	SqRepOfRR   *	Clone ( SqRepOfRR   & rep);

	friend	Bool	operator== ( SqOfRR   & lhs,  SqOfRR   & rhs);
};

Bool	operator== ( SqOfRR   & lhs,  SqOfRR   & rhs);
Bool	operator!= ( SqOfRR   & lhs,  SqOfRR   & rhs);

SqOfRR   	operator+ ( SqOfRR   & lhs,  SqOfRR   & rhs);
SqOfRR   	operator- ( SqOfRR   & lhs,  SqOfRR   & rhs);

 class 	SqItOfRR    : public ItOfRR    {
	public:
		SqItOfRR    (SqItRepOfRR   * it);

		 	size_t				CurrentIndex ()	;
		 	SqDirection	GetDirection () ;
};

 class 	SqMutatorOfRR    : public SqItOfRR    {
	public:
		SqMutatorOfRR    (SqMutatorRepOfRR   * it);

		 	void	RemoveCurrent ();
		 	void	UpdateCurrent (RR newValue);
};

 class 	SqRepOfRR    {
	protected:
		SqRepOfRR    ();

	public:
		virtual ~SqRepOfRR    ();

	public:
		virtual	SqRepOfRR   *	Clone () 										=	0 ;
		virtual	size_t			GetLength ()  									=	0 ;
		virtual	void			Compact ()											=	0 ;
		virtual	void			RemoveAll () 										=	0 ;

		virtual	RR				GetAt (size_t index) 							=	0 ;
		virtual	void			SetAt (RR item, size_t index)						=	0 ;
		virtual	void			InsertAt (RR item, size_t index)						=	0 ;
		virtual	void			RemoveAt (size_t index, size_t amountToRemove)		=	0 ;
		virtual	void			Remove (RR item)										=	0 ;

		virtual	ItRepOfRR   * 		MakeIt () 							=	0 ;
		virtual	SqItRepOfRR   *	MakeSqIt (SqDirection d)	=	0 ;
		virtual	SqMutatorRepOfRR   *	MakeSqMutator (SqDirection d)	=	0 ;
};

 class 	SqItRepOfRR    : public ItRepOfRR    {
	protected:
		SqItRepOfRR    ();

	public:
		virtual	size_t				CurrentIndex ()		=	0 ;
		virtual	SqDirection	GetDirection () 	=	0 ;

};


struct	IR {

		IR () {}		 
								 
								 

		IR ( IR& from):fTemplateName(from.fTemplateName),fArguments(from.fArguments),fRawText(from.fRawText),fHeaderDependencies(from.fHeaderDependencies),fSourceDependencies(from.fSourceDependencies),fRenames(from.fRenames)    {}

		IR& operator=( IR& rhs)
		{
			fTemplateName = rhs.fTemplateName;
			fArguments = rhs.fArguments;
			fRawText = rhs.fRawText;
			fHeaderDependencies = rhs.fHeaderDependencies;
			fSourceDependencies = rhs.fSourceDependencies;
			fRenames = rhs.fRenames;
			return *this;

		}

	St		fTemplateName;			 
														 
	SqOfSt	fArguments;				 
	St			fRawText;				 
	SqOfID   	fHeaderDependencies;
	SqOfID   	fSourceDependencies;
	SqOfRR   		fRenames;
};
 
inline Bool operator == ( IR& lhs,  IR& rhs) { return Bool ((lhs.fTemplateName == rhs.fTemplateName) &&  (lhs.fArguments == rhs.fArguments)); }

class 	ItRepOfIR   ;
class 	ItOfIR    {
	public:
		ItOfIR    (ItRepOfIR   * it);
		ItOfIR    ( ItOfIR   & from);
		~ItOfIR    ();

		 	ItOfIR   &	operator= ( ItOfIR   & rhs);

	private:
		ItOfIR    ();	
	public:
		 	Bool	Done () ;
		 	void	Next ();
		 	IR		Current () ;

	protected:
		ItRepOfIR   *	fIt;
};

 class 	ItRepOfIR    {
	protected:
		ItRepOfIR    ();

	public:
		virtual	~ItRepOfIR    ();

	public:
		virtual	Bool			Done () 			=	0 ;
		virtual	void			Next ()					=	0 ;
		virtual	IR				Current () 		=	0 ;

		virtual	ItRepOfIR   *	Clone () 			=	0 ;
};

 class 	MapElementOfStIR    {
	public:
		MapElementOfStIR    (St key, IR elt);

		MapElementOfStIR    ( MapElementOfStIR   & from);

	
		St	fKey;
		IR	fElt;
};


 class 	ItRepOfMapElementOfStIR      ;
 class 	ItOfMapElementOfStIR       {
	public:
		ItOfMapElementOfStIR       (ItRepOfMapElementOfStIR      * it);
		ItOfMapElementOfStIR       ( ItOfMapElementOfStIR      & from);
		~ItOfMapElementOfStIR       ();

		 	ItOfMapElementOfStIR      &	operator= ( ItOfMapElementOfStIR      & rhs);

	private:
		ItOfMapElementOfStIR       ();	
	public:
		 	Bool	Done () ;
		 	void	Next ();
		 	MapElementOfStIR   		Current () ;

	protected:
		ItRepOfMapElementOfStIR      *	fIt;
};


 class 	ItRepOfMapElementOfStIR       {
	protected:
		ItRepOfMapElementOfStIR       ();

	public:
		virtual	~ItRepOfMapElementOfStIR       ();

	
	public:
		virtual	Bool			Done () 			=	0 ;
		virtual	void			Next ()					=	0 ;
		virtual	MapElementOfStIR   				Current () 		=	0 ;

		virtual	ItRepOfMapElementOfStIR      *	Clone () 			=	0 ;
};

Bool	operator== ( MapElementOfStIR   & lhs,  MapElementOfStIR   & rhs);
Bool	operator!= ( MapElementOfStIR   & lhs,  MapElementOfStIR   & rhs);

 class 	MapRepOfStIR   ;

 class  ShOfMapRepOfStIR       {
	private:
		ShOfMapRepOfStIR       ();	
	public:
		ShOfMapRepOfStIR       (MapRepOfStIR   * (*cloneFunction) ( MapRepOfStIR   &), MapRepOfStIR   * ptr);			ShOfMapRepOfStIR       ( ShOfMapRepOfStIR      & src);

		~ShOfMapRepOfStIR       ();											
		 	ShOfMapRepOfStIR      & operator= ( ShOfMapRepOfStIR      & src);
		 	ShOfMapRepOfStIR      & operator= (MapRepOfStIR   * ptr);

		
		 	 MapRepOfStIR   *	operator-> () ;
		 	 MapRepOfStIR   &	operator* () ;


		
		typedef	UInt32	Counter;
		 	Counter	CountReferences () 	{ 			(((fCount)!=0 ) ? (void) 0 : _Assert ("Assertion", "(fCount)!=Nil", "./ShOfMapRepOfSt_IR.hh", 55))  ; return (*fCount); }


		
		 	 MapRepOfStIR   *	GetPointer () 		{ return (fPtr); }

		
		 	void	Assure1Reference ()	{ if (CountReferences () != 1) { BreakReferences (); } }

	private:
		MapRepOfStIR   *			fPtr;							Counter*	fCount;							MapRepOfStIR   *			(*fCloner) ( MapRepOfStIR   &);	
		 	void	BreakReferences ();
};



 class 	MapOfStIR    {
	public:
		MapOfStIR    ();
		MapOfStIR    ( MapOfStIR   & src);

	protected:
		MapOfStIR    (MapRepOfStIR   * src);

	public:
		 	MapOfStIR   & operator= ( MapOfStIR   & src);

		 	size_t	GetLength () ;
		 	Bool	IsEmpty () ;
		 	void	RemoveAll ();
		 	void	Compact ();

		 	Bool	Lookup (St key,IR* item) ;
		 	void	Enter (St key,IR newElt);
		 	void	Enter ( MapOfStIR   & items);
		 	void	Remove (IR elt);
		 	void	Remove ( MapOfStIR   & items);
		 	void	RemoveAt (St key);

		 	MapOfStIR   &	operator+= ( MapOfStIR   & items);
		 	MapOfStIR   &	operator-= ( MapOfStIR   & items);

	 	 	operator ItRepOfSt   * () ;
	 	 	operator ItRepOfMapElementOfStIR       * () ;
	
	protected:
		 	 MapRepOfStIR   *	GetRep () ;

	private:
		ShOfMapRepOfStIR       	fRep;

		static	MapRepOfStIR   *	Clone ( MapRepOfStIR   & src);

	friend	Bool	operator== ( MapOfStIR   & lhs,  MapOfStIR   & rhs);
};


 class 	MapRepOfStIR    {
	protected:
		MapRepOfStIR    ();

	public:
		virtual ~MapRepOfStIR    ();

	public:
		virtual	MapRepOfStIR   *	Clone () 						=	0 ;
		virtual	size_t	GetLength ()  								=	0 ;
		virtual	void	Compact ()										=	0 ;
	 	virtual	void	RemoveAll () 									=	0 ;

		virtual	Bool	Lookup (St key, IR* eltResult) 			=	0 ;
		virtual	void	Enter (St key, IR newElt)						=	0 ;
		virtual	void	Remove (IR elt)									=	0 ;
		virtual	void	RemoveAt (St key)								=	0 ;

		virtual	ItRepOfMapElementOfStIR       * MakeElementIt ()	=	0 ;
};




		inline	MapElementOfStIR   ::MapElementOfStIR    (St key, IR elt) :
		fKey (key),
		fElt (elt)
	{
	}


 class 	Map_ArRepOfStIR   ;
 class 	Map_ArOfStIR    : public MapOfStIR    {
	public:
		Map_ArOfStIR    ();
		Map_ArOfStIR    ( MapOfStIR   & src);
		Map_ArOfStIR    ( Map_ArOfStIR   & src);

		 	Map_ArOfStIR   & operator= ( Map_ArOfStIR   & src);

		 	size_t	GetSlotsAlloced () ;
		 	void	SetSlotsAlloced (size_t slotsAlloced);

	private:
		 	 Map_ArRepOfStIR   *	GetRep () ;
};


 class 	ArNodeOfMapElementOfStIR       {
	public:
		ArNodeOfMapElementOfStIR       (MapElementOfStIR    item);
		~ArNodeOfMapElementOfStIR       ();


		ArNodeOfMapElementOfStIR       ( ArNodeOfMapElementOfStIR      & from) :
			fItem (from.fItem)
		{
		}
		 	 ArNodeOfMapElementOfStIR      & operator= ( ArNodeOfMapElementOfStIR      & rhs)
		{
			fItem = rhs.fItem;
			return (*this);
		}


	private:
		MapElementOfStIR   	fItem;

	friend	class	ArOfMapElementOfStIR      ;
	friend	class	ForwardArItOfMapElementOfStIR      ;
	friend	class	BackwardArItOfMapElementOfStIR      ;
friend	class	ArIt_PatchBaseOfMapElementOfStIR      ;
friend	class	ForwardArIt_PatchOfMapElementOfStIR      ;
friend	class	BackwardArIt_PatchOfMapElementOfStIR      ;
};
		
 class 	ArOfMapElementOfStIR       {
	public:
		ArOfMapElementOfStIR       ();
		ArOfMapElementOfStIR       ( ArOfMapElementOfStIR      & from);
		~ArOfMapElementOfStIR       ();

		 	ArOfMapElementOfStIR      & operator= ( ArOfMapElementOfStIR      & rhs);

	public:
		 	MapElementOfStIR   		GetAt (size_t i) ;
		 	void	SetAt (MapElementOfStIR    item, size_t i);
		 	MapElementOfStIR   &		operator[] (size_t i);

		 	size_t	GetLength () ;
		 	void	SetLength (size_t newLength, MapElementOfStIR    fillValue);

		 	void	InsertAt (MapElementOfStIR    item, size_t index);
		 	void	RemoveAt (size_t index);
		 	void	RemoveAll ();

		 	Bool	Contains (MapElementOfStIR    item) ;

		
		 	size_t	GetSlotsAlloced () ;
		 	void	SetSlotsAlloced (size_t slotsAlloced);

		 	void	Skrunch ();

	protected:
		size_t			fLength;					size_t			fSlotsAllocated;			ArNodeOfMapElementOfStIR      *	fItems;

	friend	class	ForwardArItOfMapElementOfStIR      ;
	friend	class	ForwardArIt_PatchOfMapElementOfStIR      ;
	friend	class	BackwardArItOfMapElementOfStIR      ;
	friend	class	BackwardArIt_PatchOfMapElementOfStIR      ;
};

 class 	ArIt_PatchBaseOfMapElementOfStIR      ;
 class 	Ar_PatchOfMapElementOfStIR       : public ArOfMapElementOfStIR       {
	public:
		Ar_PatchOfMapElementOfStIR       ();
		Ar_PatchOfMapElementOfStIR       ( Ar_PatchOfMapElementOfStIR      & from);
		~Ar_PatchOfMapElementOfStIR       ();

		 	Ar_PatchOfMapElementOfStIR      & operator= ( Ar_PatchOfMapElementOfStIR      & rhs);

	
	public:
		 	void	SetLength (size_t newLength, MapElementOfStIR    fillValue);
		 	void	InsertAt (MapElementOfStIR    item, size_t index);
		 	void	RemoveAt (size_t index);
		 	void	RemoveAll ();
		 	void	SetSlotsAlloced (size_t slotsAlloced);
		 	void	Skrunch ();

	
	public:
		 	Bool	HasActiveIts () ;					 	void	PatchViewsAdd (size_t index) ;				 	void	PatchViewsRemove (size_t index) ;			 	void	PatchViewsRemoveAll () ;					 	void	PatchViewsRealloc () ;				
	private:
		ArIt_PatchBaseOfMapElementOfStIR      *	fIts;

	friend	class	ArIt_PatchBaseOfMapElementOfStIR      ;
};

 class 	ArIt_PatchBaseOfMapElementOfStIR       {
	public:
		ArIt_PatchBaseOfMapElementOfStIR       ( Ar_PatchOfMapElementOfStIR      & data);
		ArIt_PatchBaseOfMapElementOfStIR       ( ArIt_PatchBaseOfMapElementOfStIR      & from);
		~ArIt_PatchBaseOfMapElementOfStIR       ();

		 	ArIt_PatchBaseOfMapElementOfStIR      &	operator= ( ArIt_PatchBaseOfMapElementOfStIR      & rhs);

		 	MapElementOfStIR   		Current () ;
		 	size_t	CurrentIndex () ;

	public:
		 	void	PatchAdd (size_t index);				 	void	PatchRemove (size_t index);				 	void	PatchRemoveAll ();						 	void	PatchRealloc ();				
	protected:
		 Ar_PatchOfMapElementOfStIR      * 		fData;
		 ArNodeOfMapElementOfStIR      *			fStart;				 ArNodeOfMapElementOfStIR      *			fEnd;				 ArNodeOfMapElementOfStIR      *			fCurrent;			ArIt_PatchBaseOfMapElementOfStIR      *	fNext;

	friend	class	Ar_PatchOfMapElementOfStIR      ;
};

	inline	size_t	ArIt_PatchBaseOfMapElementOfStIR      ::CurrentIndex () 
	{
		return ((fCurrent-fStart)+1);
	}
	inline	void	ArIt_PatchBaseOfMapElementOfStIR      ::PatchAdd (size_t index)
	{
				((index >= 1) ? (void) 0 : _Assert ("Requirement", "index >= 1", "./ArOfMapElementOfSt_IR.hh", 435)) ;

		fEnd++;
					(((fData)!=0 ) ? (void) 0 : _Assert ("Assertion", "(fData)!=Nil", "./ArOfMapElementOfSt_IR.hh", 438))  ;
				(((fEnd-fStart) == fData->GetLength ()) ? (void) 0 : _Assert ("Assertion", "(fEnd-fStart) == fData->GetLength ()", "./ArOfMapElementOfSt_IR.hh", 439)) ;		
		
				((index <= (fEnd-fStart)) ? (void) 0 : _Assert ("Requirement", "index <= (fEnd-fStart)", "./ArOfMapElementOfSt_IR.hh", 441)) ;
		if (index <= CurrentIndex ()) {
			fCurrent++;
		}
	}
	inline	void	ArIt_PatchBaseOfMapElementOfStIR      ::PatchRealloc ()
	{
				(((fEnd-fStart) == fData->GetLength ()) ? (void) 0 : _Assert ("Requirement", "(fEnd-fStart) == fData->GetLength ()", "./ArOfMapElementOfSt_IR.hh", 466)) ;				if (fStart != fData->fItems) {
				ArNodeOfMapElementOfStIR      *	oldStart	=	fStart;
			fStart = fData->fItems;
			fCurrent = fData->fItems + (fCurrent-oldStart);
			fEnd = fData->fItems + (fEnd-oldStart);
		}
	}


inline	void	Ar_PatchOfMapElementOfStIR      ::PatchViewsAdd (size_t index) 
{
	for (ArIt_PatchBaseOfMapElementOfStIR      * v = fIts; v != 0 ; v = v->fNext) {
		v->PatchAdd (index);
	}
}
inline	void	Ar_PatchOfMapElementOfStIR      ::PatchViewsRealloc () 
{
for (ArIt_PatchBaseOfMapElementOfStIR      * v = fIts; v != 0 ; v = v->fNext) {
		v->PatchRealloc ();
	}
}
inline	void	Ar_PatchOfMapElementOfStIR::InsertAt (MapElementOfStIR    item, size_t index)
{
	ArOfMapElementOfStIR      ::InsertAt (item, index);
	PatchViewsAdd (index);
	PatchViewsRealloc ();
}


 class 	Map_ArRepOfStIR    : public MapRepOfStIR    {
	public:
		Map_ArRepOfStIR    ();

		virtual 	MapRepOfStIR   *	Clone () ;
		virtual 	size_t	GetLength () ;
		virtual 	void	Compact ();
	 	virtual 	void	RemoveAll ();

		virtual 	Bool	Lookup (St key, IR* eltResult) ;
		virtual 	void	Enter (St key, IR newElt);
		virtual 	void	Remove (IR elt);
		virtual 	void	RemoveAt (St key);

		virtual 	ItRepOfMapElementOfStIR       * MakeElementIt ();


		Ar_PatchOfMapElementOfStIR       	fData;

	friend	class	Map_ArOfStIR   ;
	friend	class	Map_ArItRepOfStIR   ;
};


void	Map_ArRepOfStIR   ::Enter (St key, IR elt)
{
	register	size_t length = fData.GetLength ();

	for (register size_t i = 1; i <= length; i++) {
		if (fData[i].fKey == key) {
			fData[i].fElt = elt;
			return;
		}
	}

	size_t index = i;
	fData.InsertAt (MapElementOfStIR    (key, elt), index);
}

Lewis Gordon Pringle, Jr.                                (lewis@sophists.com)


Newsgroups: gnu.gcc.bug