[net.lang.c] Bug in 4.3 C

rokicki@navajo.STANFORD.EDU (Tomas Rokicki) (08/31/86)

[ `---\-  For the plane eater ]

/*
 *   This program should print out:
 *   -1 0
 *   because the subtraction should be done with signed
 *   arithmetic; it did under 4.2 bsd on a VAX.  Now,
 *   however, under 4.3 bsd, it prints out
 *
 *   -1 1
 *
 *   Anyone know to whom I should post this bug?
 */
main () {
  register unsigned char a=1, b=2 ;

  printf("%d %d\n", ((int)(a))-((int)(b)), ((int)(a))-(int)(b))) > 1 ) ;
}

--tom

jsdy@hadron.UUCP (Joseph S. D. Yao) (09/16/86)

In article <809@navajo.STANFORD.EDU> rokicki@navajo.STANFORD.EDU (Tomas Rokicki) writes:
>/*   This program should print out: -1 0
> *   however, under 4.3 bsd, it prints out -1 1 */
>main () {
>  register unsigned char a=1, b=2 ;
>  printf("%d %d\n", ((int)(a))-((int)(b)), ((int)(a))-(int)(b))) > 1 ) ;
>}

Your parenthesisation is bad:  in this form, no compiler could
accept it.

printf("%d %d\n", ((int)(a))-((int)(b)), ((int)(a))-(int)(b))) > 1 );
      1		  23   33 32 23   33 32  23   33 32 2   22 210     -1

I'm not suggesting that this is your entire problem; but why don't
you turn on the sm [showmatch] option of vi [which I normally hate],
re-write this line, and try it again?  Then post the results.
-- 

	Joe Yao		hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}
			jsdy@hadron.COM (not yet domainised)