Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!killer!ames!lll-tis!lll-winken!uunet!mcvax!ukc!reading!onion!cf-cm!cybaswan!iiit-sh
From: iiit-sh@cybaswan.UUCP (s.hosgood)
Newsgroups: comp.lang.c
Subject: Re: Re: Puzzle on unsigned promotions
Summary: K&R didn't have 'unsigned' originally..
Message-ID: <28@cybaswan.UUCP>
Date: 8 Jul 88 20:26:45 GMT
References: <736@vsi.UUCP> <12251@mimsy.UUCP> <565@unh.UUCP>
Distribution: comp
Lines: 23

Here at Swansea, we used to have an ancient C-compiler in the days
of V6 Un*x - in those days there was no unsigned' type, many people used to
use 'char *' as a kludge.

When K&R first came out it was in the 'documents with unix' distribution, but
on V7 it wasn't distributed as the authors decided to sell the book by then. I
presume they missed points like the sign-extension properties of 'unsigned'
during revision...

I found a similar problem to the above-mentioned occurs with assigning
constants. K&R don't really seem to specify if they consider a constant to
be signed or unsigned. However, they *do* seem to say that constants behave
like 'int's unless they are too long to be 'int', in which case they magically
become 'long'. I once actually had to write a compiler from scratch, and the
assignment:

	long	temp;

	temp = 0xFFFF;

..gave rise to the question of what to do? - treat the constant as an 'int'
of -1 and sign-extend, or treat it as an unsigned bit-pattern and just
zero-fill it? I chose the latter, but I never found a satisfactory answer
from K&R!