Eep, OnBoardC messes up nested for loops in certain
cases. This is a very strange bug. If you do not
include the first argument (for(1st; 2nd; 3rd) {...})
then it runs for ceil(n/2) where n the limiting number.
However putting a function call or a variable
declaration before the inner loop makes it work.
for(int i=0; i<5; i++) //i.e. if it does fail, the
number of times it runs here is 2,
{
//FrmHelp(1);
for(; 0; 1) break;
//--------
//note that a function call here after the loop
doesn't fix it
FrmHelp(2);
}
See the attached code for more cases (choose 'about
BadLoop' to run it). Tested with OnBC 2.4.1m
Project file
Rsrc file
Logged In: YES
user_id=1048900
I encountered the same thing recently. The following did
something utterly strange:
<PRE>
UInt16 array2D[10][10];
void func()
{
int i = 0;
int j = 0;
for (;i < 10; ++i)
for (;j < 10; ++j)
func2(array2D[j][i]);
}
</PRE>