[huskerlug] Re: More of a GCC problem.

  • From: cdelgad2@xxxxxxxxxxxxxx
  • To: huskerlug@xxxxxxxxxxxxx
  • Date: Tue, 18 Mar 2003 09:59:51 -0600 (CST)

Ok, lets see if I understand you correctly.

> int iBalance = 0;
> int iLabelNode[iBalance];
> 
> The variable iBalance later changes to a larger value.

So the size of your array size = 0. and iBalance is != 0 a couple of lines down.

> puts("<------------- FlowGraph Crap -------------->");
>         for (UINT m = 1; m <= oListLabel.Count(); ++m)
>         {
>                 printf("%s = %d\n", oListLabel.Value(m), iLabelNode[m-1]);
>         }
> 
>         printf("iLabelNode[0] = %d\n", iLabelNode[0]);
> 
>         //get actual count
>         m_iNodeCount -= iBalance;
> 
>         printf("iLabelNode[0] = %d\n", iLabelNode[0]);
> 
>         //create nodes
>         Node* pNode = 0;
>         for (int y = 0; y < m_iNodeCount; ++y)
>         {
>                 pNode = new Node;
>                 pNodeArray[y] = pNode;
>         }
>         printf("iLabelNode[0] = %d\n", iLabelNode[0]);  //<-- screw up here

> 
> PORTION OF OUTPUT
> <------------- FlowGraph Crap -------------->
> IL_0006: = 4
> IL_000e: = 6
> iLabelNode[0] = 4
> iLabelNode[0] = 4
> iLabelNode[0] = 134587360

I'm really confused about your output.  The array size you declared above is =
0, therefore the is no space for anything.  But still you manage to print out
things from iLabelNode[0] and iLabelNode[1], which don't exist because the size
of iLabelNode = 0.  I think iBalance should be initialized to 1 (int iBalance =
1) so there is 1 space in that array.  This looks like a mistake I make a lot. 
I get initialization of arrays and referencing arrays confused.  if I type:

int array_of_int[1] ;

It means that I have only space for one thing:

array_of_int[0] = something;

If I initialize the array like this:

int array_of_int[2] ;

That means I have to spots to put information:

array_of_int[0] = something, array_of_int[1] = something + 1 ;

I hope it helps, but if you could send in some more code (preferably so we can
duplicate your error) we might be able to understand your problem a little 
better.

L8R,

-Cesar


----
Husker Linux Users Group mailing list
To unsubscribe, send a message to huskerlug-request@xxxxxxxxxxxxx
with a subject of UNSUBSCRIBE


Other related posts: