Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!adm!DHowell.ElSegundo@Xerox.COM From: DHowell.ElSegundo@Xerox.COM Newsgroups: comp.lang.c Subject: Re: Weird C code as test for employment Message-ID: <8771@brl-adm.ARPA> Date: Wed, 12-Aug-87 19:12:47 EDT Article-I.D.: brl-adm.8771 Posted: Wed Aug 12 19:12:47 1987 Date-Received: Sat, 15-Aug-87 02:33:57 EDT Sender: news@brl-adm.ARPA Lines: 31 In some previous article, someone wrote: ... >char *c[] = { "ENTER", "NEW", "POINT", "FIRST" }; >char **cp[] = { c+3, c+2, c+1, c }; >char ***cpp = cp; [extra asterisk deleted] ... > printf("%s ", *--*++cpp+3); In article <6253@brl-smoke.ARPA> Doug Gwyn writes: >In article <183@xyzzy.UUCP> throopw@xyzzy.UUCP (Wayne A. Throop) writes: >>I don't get it. What lvalue rules are violated by the above? >What I originally thought might be wrong is that in the process of >expanding the expression *--*++cpp at one point one is trying to >evaluate --(cp+2) (or something like that), and it was not (and still >is not) clear to me that (cp+2) qualifies as a modifiable lvalue. >Perhaps one can deduce this from the rules but I sure didn't. The expression would be grouped as (*(--(*(++cpp))))+3, so the operand to -- is (*(++cpp)). Before the expression, (due to a previous ++cpp) the value of cpp was &cp[1]. ++cpp changes this to &cp[2]. *++cpp is thus *&cp[2], which is cp[2], which is as far as I know an acceptable lvalue. So the obfuscated expression is not illegal. But I wouldn't mind if legislation were passed making it so. :-) Dan DISCLAIMER: "My opinions are not Xerox copies!"