This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Internal Compiler Error
- To: egcs-bugs at egcs dot cygnus dot com
- Subject: Internal Compiler Error
- From: Cheong Siew Ann <cheong at tristan dot tn dot cornell dot edu>
- Date: Mon, 28 Feb 2000 16:05:28 -0500 (EST)
Hi,
I was using insert_iterators to copy the contents between two vectors, but
faced this strange internal compiler error.
My source codes are attached, and the offending line is line 26 in
CellularAutomata.h.
I can work around the problem, but I guess for the sake of other
programmers trying the same stunt I should report this bug.
Thanks for your time.
Best Regards,
Siew-Ann Cheong
#include <cstdlib>
#include <iostream>
#include "MarketCrashModels.h"
#include "CellularAutomata.h"
main(int argc, char** argv)
{
void PrintUsage(char* progname);
int numberOfTraders;
int totalTime;
double pRisk;
double coordinationNumber;
// parse command line arguments
if (argc < 5)
{
PrintUsage(argv[0]);
exit(1);
}
else
{
numberOfTraders = atoi(argv[1]);
pRisk = atof(argv[2]);
coordinationNumber = atof(argv[3]);
totalTime = atoi(argv[4]);
}
MarketCrashSimulation(numberOfTraders,pRisk,coordinationNumber,totalTime);
CellularAutomata<bool> market(numberOfTraders);
// market.ShowState();
vector<bool> newState;
for (int i = 0; i < numberOfTraders; i++)
newState.push_back(i);
market.SetState(&newState);
}
// PrintUsage(): Instructions on how to use the program
void PrintUsage(char* progname)
{
cout << "Usage:\t" << progname;
cout << "\t<arg1> <arg2> <arg3> <arg4>" << endl;
cout << "\t<arg1> = system size" << endl;
cout << "\t<arg2> = noise parameter" << endl;
cout << "\t<arg3> = coordination number" << endl;
cout << "\t<arg4> = length of simulation" << endl;
}
#ifndef _CELLULAR_AUTOMATA_H_
#define _CELLULAR_AUTOMATA_H_
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>
template<class T>
class CellularAutomata
{
public:
CellularAutomata(int systemSize)
{
state = new vector<T>;
neighborhood = new vector<int>[systemSize];
}
virtual ~CellularAutomata()
{
delete state;
delete [] neighborhood;
}
void SetState(const vector<T>* newState)
{
state->clear();
insert_iterator< vector<T>* > ii(state, state->begin());
copy(newState->begin(), newState->end(), state->begin());
// Notify observers whenever state is changed
}
void ShowState()
{
ostream_iterator<T> iter (cout, " ");
copy(state->begin(), state->end(), iter);
}
protected:
vector<T>* state;
vector<int>* neighborhood;
};
#endif