P
Prasad
Hi folks,
I am trying to debug the following program. Debugging the core file
revealed segfault at possibleFlows[k][m]=0 when values of
states=36, labels=40. It works fine for lesser values.
What could be the reason? Integer overflow or out of memory? Am i
missing something obvious?
I am using ubuntu and GNU g++.
int main()
{
const int states=36, labels=40;
int fromLabels=labels, toLabels=labels;
int fromStates=states, toStates=states;
int successors[fromStates][toStates];
int stateMatrix[fromStates][toStates][fromLabels][toLabels];
int possibleFlows[states][fromLabels][toLabels];
//Initialise all possible flows to 0
for(int i=0;i<states;i++)
for(int k=0;k<fromLabels;k++)
for(int m=0; m<toLabels;m++)
possibleFlows[k][m]=0; //Segmentation fault here
//Populate with given values
//S0
possibleFlows[0][1][0]=1;
possibleFlows[0][2][0]=1;
.........................rest of the
code....................................
I am trying to debug the following program. Debugging the core file
revealed segfault at possibleFlows[k][m]=0 when values of
states=36, labels=40. It works fine for lesser values.
What could be the reason? Integer overflow or out of memory? Am i
missing something obvious?
I am using ubuntu and GNU g++.
int main()
{
const int states=36, labels=40;
int fromLabels=labels, toLabels=labels;
int fromStates=states, toStates=states;
int successors[fromStates][toStates];
int stateMatrix[fromStates][toStates][fromLabels][toLabels];
int possibleFlows[states][fromLabels][toLabels];
//Initialise all possible flows to 0
for(int i=0;i<states;i++)
for(int k=0;k<fromLabels;k++)
for(int m=0; m<toLabels;m++)
possibleFlows[k][m]=0; //Segmentation fault here
//Populate with given values
//S0
possibleFlows[0][1][0]=1;
possibleFlows[0][2][0]=1;
.........................rest of the
code....................................