Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-crg!lll-lcc!pyramid!voder!apple!kanner From: kanner@apple.UUCP (Herbert Kanner) Newsgroups: comp.lang.c Subject: incrementing after a cast Message-ID: <349@apple.UUCP> Date: Wed, 3-Dec-86 14:37:17 EST Article-I.D.: apple.349 Posted: Wed Dec 3 14:37:17 1986 Date-Received: Thu, 4-Dec-86 00:16:40 EST Distribution: net Organization: Apple Computer, Inc., Cupertino, USA Lines: 24 Keywords: cast, increment, postincrement We would like to solicit some opinions on the legality of the following, which is one way of implementing varargs for, e.g., printf: foo() { sometype L; char *chp; L = *((sometype *) chp)++; } Both the portable C compiler and lint happily accept this construct. The idea of the cast is to force chp to be incremented by the size of sometype. Our problem arises with the allegation that K&R makes this construct illegal. On page 214 (syntax summary), the only legal context for ++ is given to be lvalue++, and (type-name) expression is a case of expression which, according to that syntax, cannot be an lvalue. -- Herb Kanner Apple Computer, Inc. {idi, ios, nsc}!apple!kanner