Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!lll-crg!ames!ucbcad!ucbvax!decvax!linus!philabs!micomvax!musocs!mcgill-vision!mouse
From: mouse@mcgill-vision.UUCP (der Mouse)
Newsgroups: comp.lang.c
Subject: Re: incrementing after a cast
Message-ID: <567@mcgill-vision.UUCP>
Date: Tue, 9-Dec-86 04:58:32 EST
Article-I.D.: mcgill-v.567
Posted: Tue Dec  9 04:58:32 1986
Date-Received: Sun, 14-Dec-86 08:52:10 EST
References: <349@apple.UUCP> <2319@mtgzz.UUCP>
Distribution: net
Organization: McGill University, Montreal
Lines: 42

In article <2319@mtgzz.UUCP>, bds@mtgzz.UUCP writes:
> In article <349@apple.UUCP>, kanner@apple.UUCP (Herbert Kanner) writes:
>> 		L = *((sometype *) chp)++;
>> Our problem arises with the allegation that K&R makes this construct
>> illegal.
> By parenthesising the expression:
> 	L = (*((sometype *) chp))++
> Then [it's legal].
> Happily, it is the one you want.

I certainly hope not.  The intent was clearly to increment chp by
sizeof(sometype), or something very much like that.  Your proposed
parse results in an expression that doesn't touch chp; even *it* won't
be legal unless "sometype" can have ++ applied to it - for it's
something of type "sometype" that it's ++ing.

You also mention (I deleted it) that this parse is generated even
without the parentheses.  Well, I don't know what compiler you're
using.  Here is what my machine (VAX750/MtXinu4.3+NFS) gives:

	% cat x.c
	main()
	{
	 int i;
	 int j;
	 char *cp;
	
	 cp = (char *) &i;
	 j = *((int *)cp)++;
	}
	% cc x.c
	"x.c", line 8: illegal lhs of assignment operator
	%

					der Mouse

USA: {ihnp4,decvax,akgua,utzoo,etc}!utcsri!mcgill-vision!mouse
     think!mosart!mcgill-vision!mouse
Europe: mcvax!decvax!utcsri!mcgill-vision!mouse
ARPAnet: think!mosart!mcgill-vision!mouse@harvard.harvard.edu

[USA NSA food: terrorist, cryptography, DES, drugs, CIA, secret, decode]