Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!mcnc!ncsu!uvacs!edison!steinmetz!davidsen From: davidsen@steinmetz.UUCP (Davidsen) Newsgroups: net.lang.c Subject: Re: Casting a postdecrement operand Message-ID: <815@steinmetz.UUCP> Date: Tue, 24-Jun-86 15:39:25 EDT Article-I.D.: steinmet.815 Posted: Tue Jun 24 15:39:25 1986 Date-Received: Fri, 27-Jun-86 05:13:06 EDT References: <114@romp.UUCP> <2842@utcsri.UUCP> <1273@ulysses.UUCP> <786@steinmetz.UUCP> <1295@ulysses.UUCP> Reply-To: davidsen@kbsvax.UUCP (Davidsen) Organization: GE CRD, Schenectady, NY Lines: 49 In article <1295@ulysses.UUCP> jss@ulysses.UUCP (Jerry Schwarz) writes: >> >> The variable 'cbap' is a pointer. The cast '(struct abc *)' is a >> pointer cast. I can use '((struct abc *)cbap)' with indirects and >> subscripts and anywhere that I can use an Lvalue, so I really believe >> that the expression is legal. >> -bill davidsen > >Being a pointer value is not the same as being an lvalue. The places >that require lvalues are left hand side of assignments, and operands >of the increment and decrement operations. In none of these locations >is '((struct abc*)cbap)' legal. >> subscripts and anywhere that I can use an Lvalue, so I really believe ^^^^^^ A thousand pardons! I was thinking about Lvalues, and wrote Lvalue where I meant "address value". The point I was making (trying to amke) was that the result of the cast operation is legen *in* an Lvalue, where a pointer would be, not that I thought it was an Lvalue as is. Example: *((float *) ptr) = 4.5; /* ptr is char * type */ The other question was the legality of a cast on increment, and rather than read books and standards, I actually tried it, based on the theory that what happened in most places is "current practice". So far I have found 3 of seven compilers which compile code for ((float *) ptr)++; /* ptr type is char * */ so I make no claims one way or the other. NOTE: I am not claiming that either of these is portable or useful, but that's not the same thing as valid. Current practice is why enums are done as integers rather than being truly a distinct data type. They were added because the preprocessor ran out of symbol space as far as I know. Thanks to the people who pointed out the poor explanation in the earlier posting. All were polite except one jerk who sent six screens of flames and a ficticious .signature at the end. I hope this didn't confuse anyone. -- -bill davidsen ihnp4!seismo!rochester!steinmetz!--\ \ unirot ------------->---> crdos1!davidsen chinet ------/ sixhub ---------------------/ (davidsen@ge-crd.ARPA) "Stupidity, like virtue, is its own reward"