A friend writes to me:

Hello,

I am new at developing applications for the Palm using Metroworks
Codewarrior.  I am encountering some very strange errors while using the
Debugger that I need to fix or work around.

Essentially, passing parameters that are only used in simple
integer-to-integer assignment statements does not work correctly.  I am
getting values like 65,000 or 13,000 instead of the 1 or 2 that I passed
into the function.

I believe that Metroworks compiler optimizations sometimes have this
effect.  It may also be an error in my code relating to the stack.

I have used Metroworks Codewarrior and Metroworks Powerplant on the Mac to
develop C and C++ applications in the past.  I have encountered errors
in the past where variables that are no longer considered to be in use are
filled with junk values.

If anyone has any suggestions on how to fix this problem, please e-mail
me. Thanks.

Chester


sample code:

1)

inside a function by the name of

  Dx *DxList::getDxByIndex(int index)

this call (initially: index = 1)....

  if (D[index]==NULL)
        D[index]=dxListDB->getDxByIndex( index );       

....results in this problem (initially: idx = -65536, i=1)

  Dx *
  CDxListDB::getDxByIndex(int idx)
  {
        int i, size = getSize();

        if (idx>=getSize() || idx<0) {
                return NULL;            
        }

  (after stepping over getSize(), size=2, i & idx are the same)

2)

this call (initially: size = 2)....

  setSize(size);

....results in this problem (initially: input=2, listSize=0)

  void
  List::setSize(int input)
  {
        listSize = input;
  }

  (after stepping over the assignment statement, input=2, listSize=131072)



Reply via email to