one or two bugs in /lib/c2

utzoo!decvax!ucbvax!mhtsa!allegra!honey utzoo!decvax!ucbvax!mhtsa!allegra!honey
Fri Mar 19 22:49:46 AEST 1982


the following routine breaks c2:
	main()
	{
		short	s[10];
		register short *ptr = s;
		long	l;

		printf("in: %x\n", ptr);
		l = *ptr++ & 0xFFFF;	/* auto-increment ptr's register */
		printf("out: %x\n", ptr);
	}
the dereference + mask gets compiled into cvtwl + bicl2, which c2 turns
into extvz.  when ptr is dereferenced it is incremented by 2 in cvtwl
(word operand), by 1 in extvz (byte operand).  another application of c2
replaces extvz by movzwl (word operand).  here two wrongs do make a right.

a tip of the honey hat to jfr.



More information about the Comp.bugs.4bsd.ucb-fixes mailing list