Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!lll-crg!lll-lcc!unisoft!wendyt
From: wendyt@unisoft.UUCP (Wendy Thrash)
Newsgroups: comp.lang.c
Subject: Re: Conversions/casts one more time
Message-ID: <179@unisoft.UUCP>
Date: Fri, 12-Dec-86 20:29:52 EST
Article-I.D.: unisoft.179
Posted: Fri Dec 12 20:29:52 1986
Date-Received: Mon, 15-Dec-86 20:03:59 EST
References: <176@unisoft.UUCP> <820@mtund.UUCP>
Reply-To: wendyt@unisoft.UUCP (Wendy Thrash)
Organization: UniSoft Systems; Berkeley, CA
Lines: 31

Keywords:


My program:
>> unsigned char ucf() { return 0xaa; }
>> 
>> main() {
>> 	char c;
>> 	unsigned char uc = 0xaa;
>> 
>> 	c = uc;
>> 	printf("\tc = %x, (char)uc = %x, (char)ucf() = %x\n",
>> 	  c, (char)uc, (char)ucf());
>> }

Adam Reed (mtund!adam) writes:
>Ugh. %x expects an int, so the result of feeding it a char is,
>*and ought to be*, UNDEFINED.

Golly!  Guess they've changed the language on me again.  Last I heard,
char variables were converted to int whan passed as parameters.  That meant
that when I did something like this I could see what the compiler produced
when it converted the expression to int.  Guess I'll have to go back to writing
	int i, j, k;
	...
	i = c;
	j = (char)uc;
	k = (char)ucf();
and looking at the result with adb.  It's SO hard to keep up with these things!

In case anyone wonders, the point of this question was that the 4.3 VAX C
compiler sometimes throws away casts when it's doing promotions.  I don't
believe this is correct, and those who have addressed that issue (by mail as
well as by posting) have agreed.  Thanks to all of you who wrote.