Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!seismo!rochester!ritcv!cci632!mark
From: mark@cci632.UUCP (Mark Stevans)
Newsgroups: comp.lang.c
Subject: Was that a Sun bug?
Message-ID: <1429@cci632.UUCP>
Date: Tue, 14-Jul-87 11:56:48 EDT
Article-I.D.: cci632.1429
Posted: Tue Jul 14 11:56:48 1987
Date-Received: Thu, 16-Jul-87 06:06:58 EDT
Organization: CCI, Communications Systems Division, Rochester, NY
Lines: 38
Keywords: bug comparison Sun Parallel

The current miasma of text in comp.lang.c reminds me of a bug I saw last
year on a Parallel Computers 4.2bsd system.

The Parallel is a supposedly fault-tolerant machine made out of two Sun-2
CPU boards with some other hardware thrown in.  The software is almost
completely taken from Sun's 4.2bsd: the manuals are Sun, etc..

The following function:

	foo()
	{
		char c = 2;

		if (c == 2)
			printf("c is equal to 2\n");

		if (c == (2 + 1024))
			printf("c is also equal to 1026\n");
	}	

when compiled with Parallel's C compiler would print both messages.  Examining
the assembly language code generated by the compiler revealed that "ccom"
was generating a byte comparison instruction both tests, instead of
extending the character to an int and doing a full-word comparison.

I know that there is no *real* good reason to compare characters against
integral constants that cannot fit inside char variables.  But nevertheless,
I call this a bug.  The Parallel "guru" didn't seem interested in looking
at this.  He hinted that I should read K&R, which annoyed me considerably.
I responded that this did not violate K&R -- it violated rules so basic
they are not covered in K&R: nowhere in K&R does it say that an integer X
cannot be equal to both Y and Z if Y is not equal to Z.

Anyhow, is this a bug, or am I crazy?  Is this a Parallel bug, or does it
exist on Sun 4.2 systems too?

					Mark "Imagining" Stevans
					cci632!mark