[comp.sys.amiga.tech] Manx 5.0c Bug

carry@deakin.OZ.AU (Carry Varley) (09/06/90)

/* A Serious Bug in
   Aztec C 5.0b Jun 18 1990   (C) 1990 by Manx Software Systems, Inc

 Compile options -s0o in this test case, 16 or 32 bit ints.

 In the actual code this was discovered in all optimization was on,
 and variable i was register, but kept on the stack due to other register
 usage (ie bug occurs with & without optimization). In the test case, result
 is good with optimize, bad without.

 Compile with -at option, and observe the difference.

*/

struct table {
	short Index;
	short Array[2];
} table;



main()
{
	register short i;
	short *ip;
	register struct table *sp = &table;

	table.Index = 0;
	table.Array[0] = 1;
	table.Array[1] = 2;

	i = *(ip = &sp->Array[sp->Index]);

	if(i == *ip)
		printf("Good\n");
	else
		printf("BAD Compiler\n");

}

/* C-Born Software Systems
   14 Lunan Avenue
   Drumcondra, 3215
   Australia. +61 (052) 786530 */