Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!umd5!uvaarpa!mcnc!rti!xyzzy!throopw From: throopw@xyzzy.UUCP (Wayne A. Throop) Newsgroups: comp.lang.c Subject: Question about type casting Message-ID: <546@xyzzy.UUCP> Date: 13 Jan 88 01:22:28 GMT References: <5080009@hpfcdc.HP.COM> Organization: Data General, RTP NC. Lines: 40 > boemker@hpfcdc.HP.COM (Tim Boemker) > What's wrong with this program? > main() { > int *i; > int j[1]; > ((int [1]) i) [0] = 1; > } Lint has this to say about it: t17.c ============== (4) illegal lhs of assignment operator (4) warning: i may be used before set (3) warning: j unused in function main (5) warning: main() returns random value to invocation environment In addition to the minor faults, that no exit value was provided, j was unused, and i was used before it was initialized, lint claims that the lhs of the assignment operator is illegal. Which isn't quite right, in that it really should have complained about the cast. But even if we accept the dubious legality of the cast, which is justified only by very broad interpretation of K&R, (how do you convert a pointer-valued expression to an array-valued expression, anyway?), the resulting expression being subscripted would have to be a temporary array (with, for this reason, no aliases), and the whole assignment becomes a monumentally obfuscated no-op. (In particular, it does *NOT* by any remote stretch of the imagination initialize i.) But clearly K&R did not intend to allow anything to be cast to array type, since casts are defined as conversions, and the allowable conversions do not include any that result in arrays. -- I think it's time to stop carping on the blunders of the President and give him some credit for creativity. I mean, where do you even FIND a Jewish hard-line conservative Republican pot-smoker? --- A. Whitney Brown -- Wayne Throop !mcnc!rti!xyzzy!throopw