Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site utcsri.UUCP Path: utzoo!utcsri!greg From: greg@utcsri.UUCP (Gregory Smith) Newsgroups: net.lang.c Subject: Re: Casting a postdecrement operand Message-ID: <2842@utcsri.UUCP> Date: Sun, 25-May-86 21:25:18 EDT Article-I.D.: utcsri.2842 Posted: Sun May 25 21:25:18 1986 Date-Received: Sun, 25-May-86 21:41:45 EDT References: <114@romp.UUCP> Reply-To: greg@utcsri.UUCP (Gregory Smith) Organization: CSRI, University of Toronto Lines: 27 Summary: In article <114@romp.UUCP> lwh@romp.UUCP (lwh) writes: >My version of pcc on the IBM RT PC allows the following expression: > > struct abc { char d[500]; }; > struct cba { char e[200]; }; > struct cba *cbap; > > ((struct abc *)cbap)++; > > >to increment cbap by 500. It appears that the ANSI standard doesn't say >anything about the legality of this syntax. > First, a technical point: There is nothing wrong with the `syntax', which is identical to the syntax of (( struct foobar * ) pp )++; The *semantics*, though, are a different question. You are saying 'Treat cbap as a pointer to a (struct abc); increment that pointer'. The compiler dutifully adds 500. ( You asked for it, you got it... ) This is perfectly legal, but lint might well want to prod you about it... Since you are explicitly casting the pointer, though, it should be plain that you have good reasons to do so. -- "We demand rigidly defined areas of doubt and uncertainty!" - Vroomfondel ---------------------------------------------------------------------- Greg Smith University of Toronto UUCP: ..utzoo!utcsri!greg