Article View: gnu.g++.bug
Article #879signal 11
From: Mark Kuzmycz, SD 128, 2881
Date: Wed, 02 Sep 1992 04:25
Date: Wed, 02 Sep 1992 04:25
202 lines
4011 bytes
4011 bytes
Related files included below
I recieve the following from the compiler.
/usr/local/gnu/g++ -O -I ../Include/ -target sun4 -c test.C
/usr/local/gnu/gcc: Internal compiler error: program cc1plus got fatal signal 11
*** Error code 1
make: Fatal error: Command failed for target `test.o'
However, if I comment out either #include "list.h" OR cout << "Enter size:" << flush;
then the compiler doesn't crash.
// test.C
#include "list.h"
#include "set.h"
#include <iostream.h>
int power(int number)
{
int value = 1;
for(int i =0; i < number; i++)
{
value *= 2;
}
return(value);
}
main()
{
cout << "Enter size:" << flush;
}
// list.h
#include <iostream.h>
#include "data.h"
#ifndef LIST_H
#define LIST_H
template<class Type>
class List
{
friend
ostream& operator << (ostream&, List& data);
public:
List();
~List();
public:
List& add(const Type &);
List& remove(const int);
Type& get(const int);
Type& get();
int find(Type&);
inline int& size();
List& merge(List&);
public:
Type& operator [](const int);
int operator ==(List&);
protected:
inline void checkIndex(const int);
protected:
Type **list;
int current;
int number;
};
#include "../Utilities/list.C"
#endif
// list.C
#include "list.h"
#include "error.h"
#include <memory.h>
template <class Type>
ostream& operator << (ostream& os, List<Type>& list)
{
for(int i=0; i < list.size(); i++)
{
list.list[i]->print(os);
os <<"\n";
}
return(os);
}
template <class Type>
List<Type>::List()
{
list = NULL;
current = 0;
number = 0;
}
template <class Type>
List<Type>::~List()
{
for(int i=0; i < size(); i++)
{
delete list[i];
}
delete list;
}
template <class Type>
List<Type>& List<Type>::add(const Type &data)
{
Type *newData = new Type(data);
Type **temp = new Type*[size()+1];
memcpy(temp, list, sizeof(Type *)*size());
delete list;
list = temp;
list[size()++] = newData;
return(*this);
}
template <class Type>
List<Type>& List<Type>::remove(const int index)
{
checkIndex(index);
delete list[size()--];
memcpy((list+index), (list+index+1), sizeof(Type *)*(size()-index));
return(*this);
}
template <class Type>
Type& List<Type>::get(int index)
{
checkIndex(index);
current = index;
return(*list[index]);
}
Type& List<Type>::get()
{
checkIndex(current);
return(*list[current]);
}
template <class Type>
int List<Type>::find(Type& data)
{
for(int i=0; i < size(); i++)
{
if(data == *(list[i]))
{
return(i);
}
}
return(-1);
}
template <class Type>
List<Type>& List<Type>::merge(List& list)
{
for(int i=0; i<list.size(); i++)
{
add(list[i]);
list.list[i] = NULL;
list.remove(i);
}
return(*this);
}
template <class Type>
Type& List<Type>::operator [](const int index)
{
return(get(index));
}
template <class Type>
int List<Type>::operator ==(List& list)
{
return(0); // currently unavailable
}
template <class Type>
inline int& List<Type>::size()
{
return(number);
}
template <class Type>
inline void List<Type>::checkIndex(const int index)
{
if(index >= size())
error("There is not that many elements << Index %d: Size %d >>\n",
index,
size());
}
// error.h
#ifndef ERROR_H
#define ERROR_H
#include <stdlib.h>
#include <iostream.h>
void error(const char*, ...);
#endif
Technical Details
Message-ID:
<181fnjINNds4@sol.deakin.OZ.AU>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!legolas.DEakin.oz.AU!renagadeShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!legolas.DEakin.oz.AU!renagade From: renagade@legolas.DEakin.oz.AU (Mark Kuzmycz, SD 128, 2881) Subject: signal 11 Message-ID: <181fnjINNds4@sol.deakin.OZ.AU> Sender: gnulists@ai.mit.edu Reply-To: renagade@legolas.deakin.oz.au Organization: Sun Microsystems, Inc. Distribution: gnu Date: Wed, 2 Sep 1992 04:25:23 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 204