Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!brl-adm!brl-sem!ron
From: ron@brl-sem.ARPA (Ron Natalie )
Newsgroups: comp.lang.c
Subject: Re: Incrementing after a cast
Message-ID: <547@brl-sem.ARPA>
Date: Tue, 30-Dec-86 13:06:40 EST
Article-I.D.: brl-sem.547
Posted: Tue Dec 30 13:06:40 1986
Date-Received: Tue, 30-Dec-86 21:38:57 EST
References: <2029@brl-adm.ARPA>
Organization: Electronic Brain Research Lab
Lines: 30

In article <2029@brl-adm.ARPA>, .csnet"@relay.cs.net> writes:
> If you insist on being strict, here's a definition of ((sometype *)p)++ 
> which will work on any machine:
> 
> 	"Think of the bits refered to as p as a (sometype *).
> 	 If don't have enough bits or you have too many bits 
> 	 do something reasonable.  Now increment the (sometype *)
> 	 you're thinking of.  Now put the results back into p.  
> 	 If you	 don't have enough bits or you have too many bits, 

Actually, that is not how cast works, so your definition is far
from "strict."  Consider instead the following:

	"Ignore casts when applied to lvalues."

Since
	( (type1 *) p)++

is defined to mean
	((type1 *) p) = ((type1 *) p) + 1

What gives the compiles heartburn is the cast to the lvalue, and if
you just ignore it, then you get what I think you are looking for.

However, this leads to problem #2.  What should the type of the expression
be?  type1 or the original type of p?  You can probably make arguments
either way, however in a "strict" definition, you had better decide which
it is.

-Ron