Casting a postdecrement operand

Gregory Smith greg at utcsri.UUCP
Mon Jun 2 02:21:29 AEST 1986


In article <378 at dg_rtp.UUCP> throopw at dg_rtp.UUCP (Wayne Throop) writes:
>there are two interesting issues here.  First, the fact that the
>compiler allows a cast to be used as an lvalue is bogus in the first
>place. That compiler, quite simply, allowed an illegal operation.
[me:]
>> This is perfectly legal, but lint might well want to prod you about it...
>
>It is *not* legal, perfectly or imperfectly.  And lint *had* *better*
>prod you about it.  (It does, by the way.  It says "illegal lhs of
>assignment".)

>...once you have cast the pointer, you cannot use the cast
>expression as an lvalue.  K&R say this is illegal, Harbison and Steele
>say this is illegal, and the ANSI draft says this is illegal.  I mean,
>when the Father, the Son, and the Holy Ghost say it's illegal, I say it
>is then, now, and evermore, *ILLEGAL*.
>-- 
>Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw

I stand corrected. I couldn't find anything explicitly forbidding or
allowing this in K&R, ( I still can't ) so I gave that compiler the
benefit of the doubt, without trying it here. Reasonable semantics
could be defined for the operation, but I don't know how useful it is.

-- 
"We demand rigidly defined areas of doubt and uncertainty!" - Vroomfondel
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg



More information about the Comp.lang.c mailing list