[comp.sys.amiga.tech] MANX 5.0 Bugs

cg377170@cygnus.uucp (Corey Gehman) (06/10/90)

I've found another bug in Manx 5.0 but I'm not sure if it's known or not.
The following loop seems to add stuff to element 0 and nothing to the
rest.  It's an int array and everything has been initilized before.

   for (i=1;i<=MAX_MONS_LEVEL; i++)
      m_level[i] += m_level[i-1];

It's the "+=" that's doing it because the following works right:

   for (i=1;i<=MAX_MONS_LEVEL; i++)
      m_level[i] = m_level[i] + m_level[i-1];

But "+=" works elsewhere just fine, so it's some weird connection between the
loop, array, and/or the "+=".


But the real reason for this posting is to find out if Manx has a bug fix
out yet.  I haven't been following 5.0 reports here very closely so I
apologize if this has been gone over a thousand times before.


Thanks,
Corey Gehman
cg377170@eng.clemson.edu

walton@tybalt.caltech.edu (Steve Walton) (06/13/90)

cg377170@cygnus.uucp (Corey Gehman) writes:


>   for (i=1;i<=MAX_MONS_LEVEL; i++)
>      m_level[i] += m_level[i-1];

Maybe this is obvious, but:  you do know this code, as posted, needs the
m_level array to be declared as m_level[MAX_MONS_LEVEL+1], right?
--
Stephen Walton, srw@csun.edu, Cal State Northridge
posting from Caltech until my feed is fixed

cg377170@cygnus.uucp (Corey Gehman) (06/13/90)

Just so everyone can prove it to {him/her}self.  The following short program:

/* test manx 5.0 bug */

int array[20];

main()
{
   int i;

   for (i=0;i<20;i++) array[i]=1;

   for (i=1;i<20;i++) array[i] += array[i-1];

   for (i=0;i<20;i++) printf("array[%d]=%d\n",i,array[i]);
}

compiled with no cc flags and linking clib only.

prints out the following:

array[0]=2
array[1]=2
array[2]=2
...
array[18]=2
array[19]=1


Now, unless, I'm a completely idiot (which is possible) that's wrong.


Right?

So, the bottom line.  Manx cann't add.  Simple.

--
Corey Gehman
cg377170@eng.clemson.edu

mcmahan@netcom.UUCP (Dave Mc Mahan) (06/13/90)

 In a previous article, cg377170@eng.clemson.edu (Corey Gehman) writes:
>Just so everyone can prove it to {him/her}self.  The following short program:
>
>int array[20];
>
>main()
>{
>   int i;
>
>   for (i=0;i<20;i++) array[i]=1;
>   for (i=1;i<20;i++) array[i] += array[i-1];
>   for (i=0;i<20;i++) printf("array[%d]=%d\n",i,array[i]);
>}
>
>compiled with no cc flags and linking clib only.
>
>prints out the following:
>
>array[0]=2
>array[1]=2
>array[2]=2
>...
>array[18]=2
>array[19]=1

>Now, unless, I'm a completely idiot (which is possible) that's wrong.

Well, I ran your example through the unix compiler, and I get:

array[0]=1
array[1]=2
array[2]=3
...
array[18]=19
array[19]=20


>Right?

As a guess, I'd say your right.       :-)


>So, the bottom line.  Manx cann't add.  Simple.

Correct again.  Did you try the example by moving the declaration for
array[] inside the main() function?  Maybe you'll get different (and better)
answers.

>Corey Gehman

   -dave

csbrod@medusa.informatik.uni-erlangen.de (Claus Brod ) (06/13/90)

mcmahan@netcom.UUCP (Dave Mc Mahan) writes:

>>prints out the following:
>>
>>array[0]=2
>>array[1]=2
>>array[2]=2
>>...
>>array[18]=2
>>array[19]=1

>Well, I ran your example through the unix compiler, and I get:

>array[0]=1
>array[1]=2
>array[2]=3
>...
>array[18]=19
>array[19]=20


Looks as if Manx has a somewhat strange concept of optimizing code -
try toggling optimizer flags and stuff like this. What happens?


----------------------------------------------------------------------
Claus Brod, Am Felsenkeller 2,			Things. Take. Time.
D-8772 Marktheidenfeld, West Germany		(Piet Hein)
csbrod@medusa.informatik.uni-erlangen.de
----------------------------------------------------------------------