Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site hou3c.UUCP Path: utzoo!watmath!clyde!burl!hou3c!ka From: ka@hou3c.UUCP (Kenneth Almquist) Newsgroups: net.sources.bugs Subject: Re: Bug in compress Message-ID: <985@hou3c.UUCP> Date: Tue, 15-Jan-85 17:20:03 EST Article-I.D.: hou3c.985 Posted: Tue Jan 15 17:20:03 1985 Date-Received: Wed, 16-Jan-85 05:46:29 EST References: <53800002@ccvaxa.UUCP> Organization: Bell Labs, Holmdel, NJ Lines: 16 > The following code appears in two places in compress.c: > > while ( (c = getchar()) != (unsigned) EOF ) { > > The problem is that ((unsigned) -1) is not the same thing as ((int) -1). > The vax (and many other machines) do 32-bit compares, and say they are > equal, but other machines (correctly) do not. The program drops into > an infinite loop looking for EOF. The bug is in your C compiler, not in compress. When one operand of a binary operator is of type int and the other is of type unsigned, both operands should be converted to unsigned. Kenneth Almquist "Of course I don't read the C reference manual; it didn't come over the USENET!"