I am trying to be a GoodCoder (TM) and did a global replace to conform to
the Palm standard data type naming convention (e.g. "int" -> "Int16", etc.).
I use cygwin/GCC and have encountered a strange bug after this conversion.
Please don't ask why I am doing it this way because really I'm not; this is
just a stripped-down, bare-bones hunk of code which demonstrates the
problem. On POSE, I get "<App> just read from memory location <loc> which
is in an unallocated chunk of memory." On a real device, it just chugs and
chugs forever in some kind of infinite loop (addressing through the
'threeChars' string/array).
NOTE: the precipitating change is the "char" changing to "Char".
void NoBugTest(void) // This code works fine:
{
static const char threeChars[] = {"123"};
UInt8 i = 0;
UInt16 j=0;
FrmCustomAlert(alertWith3Vars, "<", ((threeChars[i] != NULL) ? "not NULL"
: "NULL"));
FrmCustomAlert(alertWith3Vars, "<", ((threeChars[j] != NULL) ? "not NULL"
: "NULL"));}
void BugTest(void) // This code has array bound (infinite loop) errors:
{
static const Char threeChars[] = {"123"};
UInt8 i = 0;
UInt16 j=0;
FrmCustomAlert(alertWith3Vars, "<", ((threeChars[0] != NULL) ? "not NULL"
: "NULL")); // <- OK!
FrmCustomAlert(alertWith3Vars, "<", ((threeChars[i] != NULL) ? "not NULL"
: "NULL")); // <- BAD #1!
FrmCustomAlert(alertWith3Vars, "<", ((threeChars[j] != NULL) ? "not NULL"
: "NULL")); // <-BAD #2!
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/